WhatsApp: billions of messages with a tiny team
In 2020 WhatsApp was delivering roughly 100 billion messages a day, and in 2025 Meta said more than 3 billion people use it every month. In 2014 its server side was run by about ten Erlang engineers. This lesson shows the few simple ideas that made that possible, and builds a small version you can run.
By the end you can
- Explain store and forward: why the server keeps a message only until the phone confirms it
- Say exactly what each tick means and which machine sends it
- Explain why Erlang suits millions of open connections, in plain words
- Describe what end-to-end encryption lets the server see and not see, including in groups
- Build a NestJS WebSocket gateway with a Postgres inbox that survives dropped connections
The everyday picture
Think of the parcel counter at a courier office in a busy city. A sender drops off a sealed envelope addressed to someone. The clerk does not open it. He writes it in the register, puts it in the recipient's pigeonhole, and hands the sender a receipt: "received at the counter". When the recipient comes in, the clerk hands over the envelope, the recipient signs, and the clerk tears the line out of the register. A second note goes into the sender's pigeonhole: "your envelope was collected".
The clerk never keeps a copy, never reads the letter, and keeps nothing once it is collected. His pigeonholes stay small because most envelopes are picked up within minutes. That is WhatsApp's server. The sealed envelope is end-to-end encryption, the pigeonhole is the offline queue, the receipt is the first grey tick, and the "collected" note is the second.
What the product must do
The requirement list from the What system design is lesson, filled in for a messenger:
- Functional. Send a text, photo, voice note or file to one person or a group. Deliver it even if the recipient's phone is off for a day. Show the sender whether it reached the server, reached the phone, and was read. Work on many devices per account.
- Non-functional. Messages arrive in about a second when both people are online. No message is lost, and none is shown twice. Nobody in between, including WhatsApp, can read the content. It must work on a cheap Android phone on a weak mobile connection, and it must not drain the battery.
- The unusual one. Do it with very few engineers and servers. In 2014 the team said one engineer served about 40 million users.
The last line drives everything. A small team cannot run dozens of different systems, so WhatsApp chose a few strong tools and kept the server's job narrow: move envelopes, do not keep them.