WhatsApp system design: chat, offline delivery and the three ticks
How to design WhatsApp in real interview order: connections and device copies as the numbers that matter, a light API over one long-lived connection, chat servers, a session registry and per-device offline queues built in passes, one message walked from send to read, a lab on acks, retries and duplicates behind the ticks, a lab on the reconnect storm after a lost zone, a lab on group and multi-device fan-out with end-to-end encryption, and what happens when each part fails.
The 1-minute answer
How this page follows the interview
Each phase is a section below, in the order you'd present it. Click a phase for what to say, what to write, and the trap.
New to long-lived connections, queues or idempotency? Foundations F04 (APIs and real time), F10 (queues and event streams) and F11 (idempotency and exactly-once) cover the building blocks this page puts together.
Requirements and numbers
Agree the product and the two promises behind the ticks, then size it. Two numbers matter more than messages per second: device copies per message and connections open at once. Change any input: each number comes with the decision it forces.
Functional
- 1:1 and group chats (groups up to 1,024)
- Sent, delivered and read ticks
- Messages reach offline devices when they come back
- Up to five devices per account (a phone + four linked)
- Photos, voice notes and video, by pointer
- Online, last seen and typing
Non-functional
- End-to-end encrypted: the server can't read messages
- Nothing acked is ever lost
- ✓ under 1 s; ✓✓ under 1 s when the recipient is online
- Each message shown once, in order per chat
- Light on battery and data
Out of scope (say it)
Voice and video calls, Status, payments, Channels, backups, search, spam detection in depth.
Capacity calculator
Every input is an assumption 🔶: say it out loud. Anchors: 100 billion messages a day (Meta, Oct 2020) ✅ TechCrunch 2020 = 2 billion users × 50. About 1 million phones per chat server in 2014 ✅ third party. Group share, sizes and offline time are teaching values; WhatsApp hasn't published them.
- A day is 86,400 seconds; size for the busiest hour (and New Year's Eve), not the average.
- One send, many copies. Every recipient device and the sender's own other devices get a copy.
- Little's law for queues. Copies waiting = copies/s × share offline × how long they wait.
Core entities and the API
A device sends envelopes; the server stores a copy per recipient device and deletes it on ack. What they listen for: a client-made message id, an ack from every hop, receipts that are messages too, and media by pointer.
| Entity | Key fields | Note |
|---|
The ticks: what each one means
Each tick is an ack from a different hop. Tick what has happened and see what the sender's screen shows, and why.
What WhatsApp says
- ✓ sent; ✓✓ delivered "to the recipient's phone or any of their linked devices"; blue: read. ✅ WhatsApp FAQ
- Groups: the second tick appears when everyone has received it; blue when everyone has read it. ✅ WhatsApp FAQ
- Read receipts off works both ways, but not for group chats or voice-note play receipts. ✅ WhatsApp FAQ
- The clock means not sent yet, usually a connection problem. ✅ WhatsApp FAQ
Read ticks are blue in the app; this page shows them in its own teal.
High-level design
Build it in passes and say why each box exists. Click any box to see what it does, what it owns, what's inside it and what you'd watch.
Walk one message, box by box
Asha sends "Reached the station?" to Ravi, who has a phone and a laptop. Then a group message and a lost ack. Each step lights up the path and shows what goes over the wire, what's stored and how long it takes.
Arrows show who calls whom, and the numbers give the order. Replies go back along the same line. Messages between two chat servers are drawn through the box they both belong to.
Keeping a phone connected
A connection that has to live for hours on a phone, across tunnels, sleep and deploys. These six details are what separates a demo from a product.
Data and database choices
The server is a queue, not a database: copies live until a device acks them, then they're deleted. The rest is small and hot (sessions, keys, groups) or big and separate (media).
| Data | Pick | Considered | Why not those |
|---|
The one rule to know: the send path
# On the chat server, for one send from a device.
# Illustrative; WhatsApp's own code isn't public.
def on_send(dev, msg):
if seen.contains(dev.id, msg.id): # a retry
return ack(msg.id, seen.ts(dev.id, msg.id))
for copy in msg.copies: # one per target device
queue[copy.device].append( # replicated, ordered
id=msg.id, sender=dev.id, ct=copy.ct, ttl=30*DAY)
seen.add(dev.id, msg.id, ttl=3*DAY)
ack(msg.id) # ✓ only now
for copy in msg.copies: # best effort, live path
srv = sessions.get(copy.device)
if srv: srv.deliver(copy.device) # pulls from the queue
else: push.wake(copy.device)
def on_device_ack(device, seq): # saved on the phone
m = queue[device].delete(seq)
receipts.send(m.sender, m.id, "delivered") # ✓✓Illustrative. The order is the point: dedupe, store, ack, then the best-effort live path. 🧭
Why the queue is per device
- Multi-device means a copy per device. Each device has its own identity key, so each gets its own ciphertext. ✅ Meta 2021
- Each device acks on its own schedule. The phone can be online while the laptop sleeps for a week. 🧭
- Delete on ack keeps it small. "Once your messages are delivered, they are deleted from our servers." ✅ privacy policy
- A pointer per device works too. Messenger's Iris kept one ordered queue with a pointer per destination, advanced on each successful send. ✅ Meta 2014
More database questions
Deep dive: acks, retries and the ticks
Networks lose messages and acks, servers crash, apps get killed. A sender can't tell a lost message from a lost ack, so it must retry, so copies can arrive twice. The design that survives this is store before ack, ack after save, dedupe by id. Pick a case, then switch a rule off and watch what breaks.
Lanes: Asha's phone, the chat servers, the offline queue, Ravi's phone. Arrows are numbered in order; red ones are lost or a crash. 🧭 Teaching sequence, not WhatsApp's wire format.
How many duplicates without dedupe?
Each try can lose the message or the ack. The sender retries until it gets an ack.
The rules this lab teaches
- An ack is a promise. Make it only once the copy is on replicated storage; then a crash means "deliver later", never "lost". 🧭
- Ack after save, not on arrival. The phone acks once the message is in its database; the server keeps its copy until then. 🧭
- Ids from the sender. Retries reuse the id; the server and the phone drop repeats. At-least-once plus dedupe looks like exactly-once. 🧭
- Never give up silently. After a few tries, keep it in the outbox with a clock and retry on every reconnect. ✅ WhatsApp FAQ (clock)
Deep dive: a billion connections and the reconnect storm
Holding connections is easy until many drop at once. Each reconnect needs a handshake, auth, a session write and a queue check, and refused attempts still cost the server. The chart shows attempts per second against what the surviving servers can accept. Pick a preset, then change the numbers.
Top, log scale: reconnect attempts per second (dashed, averaged over a few seconds) and how many are accepted (teal), with the accept capacity as a line. Bottom: share of dropped devices back (apricot). Fluid model in 1-second bins; a refused attempt costs 10% of an accepted one. Teaching numbers. 🧭
Three levers, in order
- Spread the retries. Exponential backoff with a random wait: "Always use randomized exponential backoff when scheduling retries." ✅ SRE book
- Refuse cheaply. Cap handshakes per server and refuse before the expensive part, with a reconnect delay hint. 🧭
- Leave room. The survivors of a zone outage must be able to hold everyone; you can't add servers during the storm. 🧭
Real numbers to quote
2012: WhatsApp tuned one FreeBSD/Erlang server from ~200K to over 2 million connections ("all contention fixes"), peaking at 2.8 million. ✅ Erlang Factory 2012
2014: about 150 chat servers at ~1 million phones each, 150 million peak connections, deliberately run at half the earlier density. ✅ third party (HighScalability)
Deep dive: groups and multi-device fan-out
End-to-end encryption means a copy per device. For a group that can be a thousand copies per message, plus a receipt from each. Sender Keys move the fan-out to the server; folding moves receipts off the sender; membership changes become the cost. Pick a preset, then change the numbers.
How the two schemes work
- 1:1 with multi-device: client fan-out. The sender encrypts the message separately for each of the recipient's devices and its own other devices. ✅ Meta 2021
- Groups: Sender Keys. Each member sends its sender key to every member pairwise once; each message is then encrypted once and the server fans the single ciphertext out. ✅ whitepaper 2016
- Removal: rotate. When a member leaves, every remaining member makes a new sender key before its next message. 🔶 Sender Keys design
Numbers to quote
Groups of up to 1,024 members since November 2022. ✅ WhatsApp blog
A phone plus up to four other devices, each with its own identity key. ✅ Meta 2021
Receipt folding isn't published by WhatsApp: the FAQ shows the group ticks, not how they're computed. ❓ say it as a choice
A message's lifecycle
On the sender's phone every message is a small state machine, shown as ticks. Click events to move it; ones that can't happen from the current state are disabled. Each event shows what fires across the system.
Edge cases interviewers love
Failure, monitoring and recovery
A chat system fails in two ways: loudly (connections drop, sends hang at the clock) and quietly (✓ arrives but ✓✓ doesn't). Click a box to take it down: red is the failed part, amber is its blast radius. Each answer covers impact, degraded mode, the alert, automatic and manual recovery, and how you'd trace it.
Tracing it back: an online recipient vs a phone in Doze
Every span carries the message id (never the content). Times are seconds from tapping send. In the slow trace the recipient's phone is asleep: the push is sent at once, but the OS delays the wake-up.
How one failure becomes three
What you'd alert on (SLOs)
| Signal | Target | Alert |
|---|
Incident playbook
The toolkit
Name the technique, then say where it goes in this design.
Making it fast, and who owns what
Server work takes milliseconds; the phone's network and its sleep decide the rest. Bars are sizing estimates, not measured figures.
| Team | Owns | Paged when… |
|---|
Senior follow-ups beyond the happy path
Interviewers pick from these themes once the design is on the board. Have one concrete answer per theme, tied to this design.
Practice ladder
Real interviews go level by level. Answer out loud before opening each one. Levels 6–7 are where Senior becomes Staff.
Sources
- How to check read receipts, WhatsApp Help Center (checked Oct 2026)
- WhatsApp Privacy Policy: delivered and undelivered messages (checked Oct 2026)
- WhatsApp Encryption Overview, technical white paper (4 Apr 2016)
- How WhatsApp enables multi-device capability, Engineering at Meta (14 Jul 2021)
- Communities now available (groups of up to 1,024), WhatsApp blog (3 Nov 2022)
- Scaling to millions of simultaneous connections, Rick Reed, Erlang Factory SF (30 Mar 2012)
- That's 'Billion' with a 'B': scaling to the next level at WhatsApp, Rick Reed, Erlang Factory SF (Mar 2014)
- How WhatsApp grew to nearly 500 million users, 11,000 cores and 70 million messages a second, HighScalability (third-party notes on the 2014 talk)
- WhatsApp is now delivering roughly 100 billion messages a day, TechCrunch (29 Oct 2020)
- Building mobile-first infrastructure for Messenger, Engineering at Meta (9 Oct 2014)
- Technology preview: Signal private group system, Signal blog (9 Dec 2019)
- WhatsApp Key Transparency white paper
- Set the priority of a message, Firebase Cloud Messaging docs (checked Oct 2026)
- Addressing cascading failures, Google SRE book
- WhatsApp problem breakdown, Hello Interview (third party, used to cross-check interview expectations)
Checked October 2026. Product behaviour is from WhatsApp's own pages (Help Center on read receipts, Privacy Policy on deleting delivered messages and keeping undelivered ones up to 30 days, the Communities post on 1,024-member groups) and Meta's engineering posts (multi-device, July 2021; Messenger's Iris queue, October 2014). Encryption details are from WhatsApp's April 2016 technical white paper (the current version's PDF couldn't be fetched for this run). Server numbers are from Rick Reed's 2012 Erlang Factory slides and a third-party summary of his 2014 talk (HighScalability), so they are old and used as orders of magnitude. The 100-billion-messages figure is Meta's, as reported by TechCrunch (Oct 2020). WhatsApp hasn't published its queue store, session registry or receipt aggregation; those parts are tagged as inferred or interview choices. Hello Interview is a third-party prep site, used only to cross-check what interviewers expect. All three labs use rounded teaching values.
System Design Mastermind · Classics
Series homeAll of Classics
6 published · 4 comingThe problems almost every loop draws from.
Uber system design, reverse-engineered: from tap to pickup
In-memory geo index sharded by map cell → rank nearby drivers by road ETA → offer to one driver with a 15 s timeout → accept with compare-and-set → push updates to both apps.
Rate limiter system design: fair limits at a million requests a second
Check every request once in the API gateway → one atomic Lua script per request on the caller's shard of a sharded Redis (token bucket for per-second, window for per-day) → 429 + Retry-After, or forward with RateLimit headers → local cache for keys already over → each rule fails open or closed on purpose.
WhatsApp system design: chat, offline delivery and the three ticks
One long-lived encrypted connection per device → the chat server stores a copy per recipient device in a replicated offline queue, then acks (✓) → session lookup, forward or push → the device saves and acks, the copy is deleted (✓✓) → a read receipt when opened. Client-made ids and dedupe at both ends, backoff with jitter on reconnect, Sender Keys for groups.
Ticketmaster system design: selling seats without double-booking
Cached reads for browsing → a seat inventory with one row per seat, sharded by event → a hold is one conditional UPDATE (only if free or expired) with a 10-minute timer → pay with a client-made idempotency key → confirm only if the hold is still yours, plus an outbox for tickets. A waiting room admits fans at the rate booking can serve.
News feed system design: fan-out, celebrities and ranking
Write each post once → fan-out workers push its id into active followers' capped Redis timelines → accounts above ~1M followers are merged at read time instead → the feed service gathers ~1,500 candidates, a light model trims them, a heavy model predicts actions, a weighted sum orders them → deletes and blocks are checked at read time, pages use a cursor.
Notification system design: push, email and SMS without spam, drops or duplicates
One Notify API with an idempotency key → a router checks dedupe, preferences, caps and quiet hours, picks live devices → per-channel queues with a transactional lane apart from bulk → workers call APNs, FCM, email and SMS with priority, expiry and a collapse id, retry 429s with backoff and delete dead tokens → campaigns paced below the provider quota, OTPs fall back to SMS.