Home
Blog
ELI5: Proxygen - High performance HTTP framework

January 10, 2022

ELI5: Proxygen - High performance HTTP framework

By Navyata Bawa

In this blog post, we explain Proxygen, a collection of C++ libraries that makes it very easy to build clients, servers, and proxies, in a way that is super simple to understand. If you're interested in learning by watching or listening, check out a video about this open source project on our Facebook Open Source YouTube channel.

Why Proxygen?

Proxygen is a collection of C++ libraries that makes it very easy to build clients, servers, and proxies. It focuses on building a high performance C++ HTTP framework with sensible defaults that includes both server and client code that's easy to integrate into existing applications.

Proxygen originally began as a project to write a customizable and high-performance HTTP(S) reverse-proxy load balancer, and was initially planned to be a software library for generating proxies, hence the name.

When data is transmitted through the interwebs, most data follows a standard or protocol called hypertext transfer protocol (HTTP). For example, if we open a web-based chat application from our computer (client), a request is sent to the server to tell it that we want to know what the most recent messages in my thread are. The server will then send back a response.

Sometimes there is a proxy, a device or server that acts on behalf of another device. It sits between the client and server and can help perform a service on both the request and the response. A reverse proxy accepts the request from a client and forwards it to the server that can actually fulfil this request, and then returns the server’s response to the client as if the proxy itself processed the request.

A load balancer may be used to distribute these incoming client requests among a bunch of servers. This ensures that no single server bears too many requests. The load balancer then returns the response from the selected server to the appropriate client.

Proxygen framework supports HTTP/1.1, HTTP/2, and HTTP/3, and provides a modern C++ HTTP library that is simple and performant. As shown in the figure below, Proxygen’s C++ HTTP stack architecture consists of 4 parts—a session, a codec, a transaction, and a handler. These parts work hand in hand to allow serializing and de-serializing of HTTP messages.

The proxygen/HTTPserver has a simple set of APIs, and is the recommended way to interface with Proxygen when acting as a server if you don't need the full control of the lower level abstractions. If you’d like to have more control, you can find all core networking abstractions under proxygen/lib.

Where is Proxygen used?

Since its early days, the Proxygen library has evolved considerably. At Meta, it is used as the basis for building many HTTP servers, proxies, and clients. Proxygen was made open sourced by Meta in 2014, and currently, many internal systems are built on top of the Proxygen core code, including parts of systems like HHVM, our photo storage Haystack, our HTTP load balancers, and it functions as the primary HTTP stack in the Facebook and Instagram apps by Meta.

Proxygen is being actively developed and new features are regularly added.

Where can I learn more?

To learn more about Proxygen, check out its Github repo for installation guidelines and samples or checkout the announcement blog post, which talks more about the background of the project and about Proxygen’s architecture in detail.

About the ELI5 series

In a series of short videos, one of our Developer Advocates on the Meta Open Source team explains a Meta open source project in a way that is easy to understand and use.

We will write an accompanying blog post (like the one you're reading right now) for each of these videos, which you can find on our YouTube channel.

To learn more about Meta Open Source, visit our open source site, subscribe to our YouTube channel, or follow us on Twitter and Facebook.


Get our newsletter

Sign up for monthly updates from Meta for Developers.

Sign up