Free s and m chat rooms
Having Thrift available freed us to split up the problem of building a chat system and use the best available tool to approach each sub-problem.The secret for going from zero to seventy million users overnight is to avoid doing it all in one fell swoop.
It is rather keeping each online user aware of the online-idle-offline states of their friends, so that conversations can begin.The primary use of a chat room is to share information via text with a group of other users.Generally speaking, the ability to converse with multiple people in the same conversation differentiates chat rooms from instant messaging programs, which are more typically designed for one-to-one communication.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.Despite those advantages, using Erlang for a component of Facebook Chat had a downside: that component needed to communicate with the other parts of the system.Fault tolerance is a desirable characteristic of any big system: if an error happens, the system should try its best to recover without human intervention before giving up and informing the user.
The results of inevitable programming bugs, hardware failures, et al., should be hidden from the user as much as possible and isolated from the rest of the system.
Since going open source a year ago (we had the gall to release it on April Fool's Day, 2007), the Thrift project has steadily grown and improved (with multiple iterations on the Erlang binding).
This isn't by any means a new technique: it's a variation of Comet, specifically XHR long polling, and/or BOSH.
Having a large-number of long-running concurrent requests makes the Apache part of the standard LAMP stack a dubious implementation choice.
Note that approach (a) changes the sending a chat message / loading a Facebook page from a one-to-one communication into a multicast to all online friends, while approach (b) ensures that users who are neither chatting nor browsing Facebook are nonetheless generating server load.