BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Facebook Open Sources Proxygen, an HTTP Framework Supporting SPDY 3.1

Facebook Open Sources Proxygen, an HTTP Framework Supporting SPDY 3.1

Leia em Português

This item in japanese

The idea behind Proxygen is not to replace Apache but having the ability to create a specialized high-performance web server that can be embedded into existing applications providing web services. Facebook initially started to build a proxy (hence the name) server in 2011, and now they are open sourcing it after the project evolved and has been tested in production for a number of years.

Why not start with Apache or nginx or another server? Facebook provided a number of reasons:

  • Ability to integrate with their existing infrastructure and tooling (Thrift, ODS)
  • Creating an event-driven library that would be used by different internal projects (Haystack, HHVM, load balancer, etc.)
  • According to Facebook, their previous HTTP infrastructure had reach some scalability limits and required “lots of workarounds”, so they wanted something that can be developed internally as desired.
  • A number of features were missing in existing HTTP servers at that time: SPDY, WebSockets, HTTP/1.1 (keep-alive), TLS false start, and specific load-scheduling algorithms.

Proxygen uses the following concepts: transaction, session, codec, and handler. A transaction represents a request-response pair exchanged between a client and a server. A sequence of such related transactions represents a session. Bytes coming from the wire are parsed into objects by a codec which associates them with a transaction. The message is eventually passed to a handler for actual processing. While it is possible to interact with the framework at this low level of codecs and transactions, developers are suggested to use higher level abstractions via an API.

Proxygen relies on

  • Folly – an open source library of C++11 components used internally by Facebook and including among others a code benchmarking framework, endian conversion primitives, optimized strings and vectors, JSON serializer, and others.
  • FBThrift – an Apache Trift branch.

Proxygen has support for SPDY 3.1 and is adding support for HTTP/2. During an in-house benchmark run by Facebook on a 32 logical core Xeon CPU E5-2670 @ 2.60GHz with 16 GB of RAM, a Proxygen echo server served up to 304,197 in-memory GET requests/sec over SPDY 3.1.

The source code released on GitHub has been tested on Ubuntu 14.04, but Facebook considers it safe to be run on other systems, without specifying which.

Rate this Article

Adoption
Style

BT