The big idea
What is WhatsApp, really?
Strip away the brand and WhatsApp does one magical thing: get a message from your phone to anyone else's — instantly, reliably, anywhere on Earth — and tell you the moment they've read it.
That one sentence hides brutal questions. How do two phones that can't talk directly reach each other? What if the other person is offline? How do you do this for 2+ billion people at once — and prove delivery with those little ✓✓ ticks?
How to read this: We add one piece at a time. Each step opens with a problem, then the smallest fix. Watch the diagram grow and the chat below come alive — by the end you'll have built the whole thing. Hit Begin.
Step 1 · The skeleton
Two phones, one server
Alice's phone and Bob's phone can't message each other directly — phones hide behind carrier networks, change IPs, and fall asleep. They need a middleman both can reach.
Design decision: Two phones behind carrier networks, changing IPs, falling asleep — they can’t talk directly. How do they exchange messages?
The call: A server in the middle that stores then forwards each message. — Alice sends to the server, which holds a copy in a Message Store and forwards to Bob. Store-and-forward — holding each message until the recipient has it — is what lets messaging survive flaky networks and sleeping phones.
Put a server in the middle. Alice sends her message to the server; it saves a copy in a Message Store and forwards it to Bob. The classic client → server → client relay — the spine of every chat app.
Store and forward: The server doesn't just pass messages along — it holds each one until the recipient has it. That single idea is what lets messaging survive flaky networks and sleeping phones.
Step 2 · Always-on
Reach Bob the instant it lands
The server is holding Alice's message — but Bob's phone isn't asking for it. Polling "any messages for me?" every second, for billions of phones, would melt the planet and still feel slow.
Design decision: The server holds Alice’s message, but Bob’s phone isn’t asking for it. How does it arrive instantly?
The call: A persistent WebSocket per phone; the server pushes on arrival. — An always-open socket flips the model — the server speaks first, delivering the moment a message lands, with no polling. One warm pipe carries messages, typing dots and receipts both ways.
Keep a persistent connection — a WebSocket — open between every phone and a Connection Server. Now the server can push the moment a message arrives. No refreshing, no polling; the pipe stays warm as long as you're online.
Push, don't poll: A WebSocket flips the web's usual model: instead of the client always asking, the server speaks first. One always-open pipe carries messages, typing dots and receipts in both directions.
Step 3 · The address book
Which server is Bob on?
At scale there isn't one connection server — there are thousands. Alice's socket lands on server #14; Bob's on server #882. Server #14 holds the message but has no idea where Bob is.
Design decision: There are thousands of connection servers. Alice is on #14, Bob on #882. How does #14 deliver to Bob?
The call: A Session Service maps user → connection server; look Bob up and route. — When Bob connects he registers his spot; to deliver, #14 asks "where’s Bob?", finds #882, and routes straight there. Service discovery turns "shout to everyone" into "deliver to exactly one place" — a fast in-memory registry (Redis).
A Session Service keeps a live registry: user → connection server. When Bob connects he registers his spot. To deliver, server #14 asks "where's Bob?", finds server #882, and routes the message straight there.
Service discovery: The registry turns "shout to everyone" into "deliver to exactly one place." It's usually a fast in-memory store (Redis), updated every time someone connects, disconnects, or roams to a new server.
Step 4 · When Bob's asleep
Deliver to someone offline
Bob's phone is off, or he's on the subway with no signal. There's no socket to push to. The message can't just vanish — and Alice shouldn't have to wait or retry.
Design decision: Bob’s phone is off or has no signal — there’s no socket to push to. What happens to the message?
The call: Queue it in Bob’s per-user Inbox Queue; drain on reconnect, then delete. — If the registry shows no live connection, the message waits in Bob’s mailbox; the moment he reconnects the server drains the queue to his phone, confirms delivery, and deletes the stored copy. The queue decouples send from receive.
If the registry shows Bob has no live connection, drop the message into his Inbox Queue — a per-user mailbox. The moment Bob reconnects, the Connection Server drains his queue to the phone, confirms delivery, and the stored copy is deleted.
Queues absorb reality: A message queue decouples "send" from "receive." Senders never block on a sleeping recipient; the queue patiently holds messages until the device shows up — seconds or days later.
Step 5 · The famous ticks
✓ sent, ✓✓ delivered, ✓✓ read
Alice wants to know what happened to her message. Did it leave her phone? Reach Bob's? Did he actually read it? Silence breeds anxiety.
Every hop sends a tiny acknowledgement back. Reaches the server → one ✓. Delivered to Bob's device → two ✓✓. Bob opens the chat → his phone reports it and the ticks turn blue. A little state machine riding the same socket.
Acks all the way down: Reliable delivery means confirmations at every step. The ticks aren't decoration — they're the visible edge of the acknowledgement protocol that guarantees no message is silently lost.
Step 6 · Group chat
One message, many phones
Alice posts in a 50-person group. We can't make her phone send 50 copies — that's slow and drains her battery. But everyone must get it, in order.
Design decision: Alice posts in a 50-person group. How does everyone get it, in order, without her phone sending 50 copies?
The call: She sends one message; a Group Service fans it out to each member. — One message tagged with the group id; the Group Service looks up members and fans out a copy to each one’s connection (or Inbox Queue if offline). One send in, N deliveries out, all server-side — fan-out on write.
She sends one message tagged with the group id. A Group Service looks up the members and fans out a copy to each one's connection — or their Inbox Queue if offline. One send in, N deliveries out, all handled server-side.
Fan-out: Fan-out is the heart of group messaging. WhatsApp fans out on write — copying to each member the instant the message lands — which keeps delivery fast for the small-to-medium groups it's tuned for.
Step 7 · Photos & video
Don't push a video down the socket
A 50 MB video can't ride the same lightweight pipe as "lol 😂". Pushing big blobs through connection servers would clog the real-time path for everyone.
Design decision: A 50 MB video can’t ride the same lightweight pipe as "lol 😂". How do you send media?
The call: Upload once to blob storage + CDN; the chat carries a pointer + thumbnail + key. — Media uploads once to blob storage fronted by a CDN near each viewer; the message carries only a small pointer, thumbnail and decryption key, and Bob fetches the blob from the nearest edge. Separate the data plane from the control plane.
Upload media once to blob storage, fronted by a CDN that caches it near each viewer. The chat message carries only a small pointer + thumbnail + decryption key. Bob's phone fetches the blob straight from the nearest CDN edge.
Separate the data plane: Tiny control messages and big media take different roads. Text flows through the fast messaging path; bytes flow through storage + CDN. Mixing them would make both worse.
Step 8 · Trust & scale
2 billion phones, zero peeking
Two hard problems at once: how do a handful of servers hold billions of live connections — and how do you promise that not even WhatsApp can read people's messages?
Connection servers are tuned to hold ~2 million sockets each, so a modest fleet covers the planet; Presence rides the same socket via heartbeats. And every message is end-to-end encrypted — the server only ever relays ciphertext it cannot decrypt.
End-to-end encryption: Keys live only on the devices. The server stores and forwards sealed envelopes — routing them perfectly while being mathematically unable to open them. Privacy by design, not by promise.
You did it
You just designed WhatsApp.
- Store-and-forward server — the relay spine between two phones.
- Persistent WebSockets so the server pushes messages instantly.
- A Session registry routes each message to the right connection server.
- Per-user Inbox Queues hold messages for offline recipients.
- Acknowledgements drive the ✓ / ✓✓ / blue-tick delivery receipts.
- A Group Service fans one message out to every member.
- Media via blob storage + CDN; only a tiny pointer rides the chat.
- ~2M sockets per server and end-to-end encryption at planet scale.