Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Facebook Chat sync conversations across windows/tabs

Tags:

facebook

chat

Sometimes while chatting if I send a message to a friend in chat in one window and switch to another window/tab where facebook is open(and naturally chat window is open too), the my msg automatically pops up there.

Similarly if a friends pings you, ping goes to all facebook loaded windows/tabs. Don't want heavy details but how does facebook manage this.

like image 904
Smiles in a Jar Avatar asked Jan 10 '12 16:01

Smiles in a Jar


1 Answers

Here's a blogpost on the subject by facebook: https://www.facebook.com/note.php?note_id=14218138919

What you want to know is most-likely described in this paragraph:

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.

like image 159
samn Avatar answered Mar 24 '23 22:03

samn