Why Facebook chat scaled so well

The answer is….aside from having a pretty amazing dev team of course, yep, Erlang. It’s basically a Comet HTTP server, with a C++ app handling the log of chat messages, and an Erlang based server to handle the polling and HTTP requests:

For Facebook Chat, we rolled our own subsystem for logging chat messages (in C++) as well as an epoll-driven web server (in Erlang) that holds online users’ conversations in-memory and serves the long-polled HTTP requests. Both subsystems are clustered and partitioned for reliability and efficient failover. Why Erlang? In short, because the problem domain fits Erlang like a glove. Erlang is a functional concurrency-oriented language with extremely low-weight user-space “processes”, share-nothing message-passing semantics, built-in distribution, and a “crash and recover” philosophy proven by two decades of deployment on large soft-realtime production systems.

It’s all here

The other really interesting thing that this mentions here is Thrift, which is the Facebook platform for enabled simple RPC communications between different apps. It’s available open source here, and if anyone has used it definitely let me know how it worked out for you.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>