System Design: WhatsApp (Walnut Chat: Signal Protocol, Per-Device Queues, Ordered Delivery, Group Keys)
Goal: Design a messaging app like WhatsApp. Ours is Walnut Chat. People send text, photos and voice notes from a phone and up to 4 more devices. Only the people in the chat can read them.
We plan for 3 billion monthly users and 100 billion messages a day. That is about 1.16 million a second on average, and 7 million a second of design capacity, the capacity we keep always on.
At the evening peak, the busiest hour of a normal day, 500 million devices are connected.
Walnut Chat is our design. WhatsApp is run by Meta. Their published facts are evidence, always with their year.
1. What We Are Building
🔒 Premium section
2. Requirements and Scale
2.1 What the System Must Do
These are the features Walnut Chat must have.
| ID | Requirement |
|---|---|
| FR1 | Register with a phone number, guarded by an optional PIN (section 15.5). Link up to 4 companion devices to one account (section 8). |
| FR2 | Send text to a person or a group. Edit a message within 15 minutes, as WhatsApp allows (WhatsApp blog, 2023). Delete it for everyone within 60 hours, as WhatsApp allows (news report, 2022) (section 7.2). |
| FR3 | Deliver each message to every device of every recipient, and to the sender's own other devices (sections 6 and 8). |
| FR4 | Show one tick, two ticks and blue ticks (section 6.5). |
| FR5 | Keep each chat in the same order on every device (section 7). |
| FR6 | Encrypt messages, media and backups end to end (sections 9, 12 and 14). |
| FR7 | Groups of up to 1,024 members, as WhatsApp (WhatsApp blog, 2022). Communities with an announcement group (section 10). |
| FR8 | Show who is online, when they were last seen and when they are typing, with privacy settings (section 11). |
| FR9 | Send photos, videos, voice notes and files of up to 2 GB, as WhatsApp (WhatsApp blog, 2022) (section 12). |
| FR10 | Wake an offline phone when a message arrives for it (section 13). |
| FR11 | Block, report and fight spam without reading any message (section 15). |
FR6 makes the rest hard. The server routes, orders and stores messages that it can never read. FR3 is the other hard one: Ethan's laptop gets its own copy of every message (section 8).
2.2 How Well It Must Do It
Speed targets use two words. p50 is the time that half of all requests beat. p99 is the time that 99 of every 100 requests beat, so it shows the slow tail.
A region is an area of the world with its own servers, such as US West (section 21). A zone is one data center building group inside a region, with its own power and network. Losing one zone must not lose data.
Availability is the share of time the service works. NFR8 uses the word ack, a short "saved" reply (section 3.1).
| ID | Requirement | Target |
|---|---|---|
| NFR1 | One tick | p99 under 200 ms on the server, same region. A chat kept in another region (section 21.3) adds one round trip, about 70 ms from San Francisco to New York (estimate) |
| NFR2 | Delivery to an online device | p50 under 200 ms, p99 under 1 s, same region |
| NFR3 | No loss | No message that got one tick is lost while its sender's phone survives. After a region loss, apps resend what got a tick in the last 5 minutes (section 21.4). Undelivered messages are deleted after 30 days, a stated limit, not a loss |
| NFR4 | Shown once | Each message is shown once on each device. A copy may arrive twice (section 6.4), and the app drops it by its message ID, a random ID set by the sender's app (section 3.1) |
| NFR5 | Order | Same order inside a chat on every device, set by one counter per chat (section 7.2). After a region loss, a resent message may sit in a different place on devices that got it before the loss (section 21.4) |
| NFR6 | Availability | 99.99% a month for send and receive |
| NFR7 | Privacy | The server never sees message content, media content or message keys |
| NFR8 | Deletion | Delivered ciphertext is deleted within about 1 hour after the ack. Undelivered ciphertext is deleted after 30 days at most |
| NFR9 | Blocks | A block applies to the next send |
Where the targets come from:
- NFR1 to NFR5. Our choices; WhatsApp publishes no speed target. One tick means the message is saved in at least 2 of 3 zones (section 6.3).
- NFR6. Our choice. A 30-day month has 43,200 minutes, and 0.01% of that is about 4.3 minutes of downtime. A whole-region loss, about 15 minutes of failover (section 21.4), is outside this target and counted apart.
- NFR7. End-to-end encryption, as WhatsApp (WhatsApp whitepaper, 2024).
- NFR8. The 30 days is WhatsApp's own limit for undelivered messages (WhatsApp privacy policy, 2021). The 1 hour is our choice (section 7.4).
- NFR9. Our choice. It costs one read per send (section 15).
2.3 The Numbers
These are planning numbers, all our assumptions unless marked. Section 17 turns them into servers.
Five load words appear in the whole post. All are counted in sends, or in deliveries when we say so.
- Daily average. A day's total spread evenly over 86,400 seconds.
- Evening peak. 2 times the daily average, our assumption, because local evenings are busiest.
- Design capacity. 3 times the evening peak, always running on the send path and the stores. Stores cannot grow in minutes.
- Event peak. 10 times the daily average, our assumption for New Year's midnight in the largest time zones.
- Event capacity. 1.25 times the event peak, set up in the two weeks before a known event. WhatsApp's 2026 World Cup final was 1.23 times its New Year peak (Meta engineering blog, 2026), so 1.25 covers it.
| What | Number | How we got it | Section |
|---|---|---|---|
| Monthly users (MAU) | 3 billion | The same size as WhatsApp's "more than 3 billion" (Meta, 2025) | 17 |
| Daily users (DAU) | 2 billion | Two thirds of MAU, because chat is opened most days. WhatsApp's last daily count was 1 billion (WhatsApp blog, 2017) | 17 |
| Devices | 4 billion | 1.3 devices per user, because most people use only a phone. 3 billion × 1.3 = 3.9 billion, rounded up | 8 |
| Sends a day | 100 billion | 2 billion DAU × 50 sends. The same as WhatsApp's "more than 100 billion" (WhatsApp blog, 2025) | 6 |
| Sends a second | 1.16 million average, 2.3 million evening peak, 7 million design capacity, 11.6 million event peak, 14.5 million event capacity | 100,000,000,000 ÷ 86,400 = 1,157,407. × 2 = 2.31 million. × 3 = 6.94 million. 1.16 million × 10 = 11.6 million. × 1.25 = 14.5 million | 6, 17 |
| Deliveries per send | 4.5 | A 1:1 send goes to 1.3 recipient devices plus 0.3 of the sender's own other devices = 1.6. A group send reaches 10 other members on average: 10 × 1.3 + 0.3 = 13.3. A quarter of sends are group sends: 0.75 × 1.6 + 0.25 × 13.3 = 4.5 | 7 |
| Deliveries a second | 5.2 million average, 10.4 million evening peak, 31 million design capacity, 52 million event peak, 65 million event capacity | 100 billion × 4.5 = 450 billion a day. ÷ 86,400 = 5.2 million, then the same factors as sends | 7, 17 |
| Connected devices at the evening peak | 500 million | 25% of DAU. WhatsApp had 147 million connected in 2014 (WhatsApp talk, 2014), and phones now close background connections | 5 |
| Device queues | About 1.1 PB | Shown in its home section | 7.4 |
| Media | About 170 PB on disk | Shown in its home section | 12.3 |
| Prekeys, public keys that let a chat start while a phone is offline | 48 TB | Shown in its home section | 9.3 |
WhatsApp's record of 30 million a second would be 26 times its daily average, but WhatsApp does not say what each counted message is. So our event peak stays at 10 times the daily average in sends, 52 million deliveries a second.
2.4 Out of Scope
We leave out voice and video calls. WhatsApp has more than 2 billion calls on a typical day (WhatsApp blog, 2025), but calls use a separate system.
We also leave out Status and Channels, payments, business messaging and AI features.
Disappearing messages get only a mention. WhatsApp offers 24 hours, 7 days or 90 days (WhatsApp blog, 2021). Each app deletes its own copy when the timer ends, so the server design does not change.
Talking to other apps, which European law now asks of WhatsApp, appears only in section 16.
3. The API and the Core Data
🔒 Premium section
4. High-Level Design
🔒 Premium section
5. Deep Dive: Connections and the Session Registry
🔒 Premium section
6. Deep Dive: 1:1 Delivery, Acks and Receipts
🔒 Premium section
7. Deep Dive: Ordering and Per-Device Queues
🔒 Premium section
8. Deep Dive: Multi-Device
🔒 Premium section
9. Deep Dive: End-to-End Encryption
🔒 Premium section
10. Deep Dive: Groups
🔒 Premium section
11. Deep Dive: Presence and Typing
🔒 Premium section
12. Deep Dive: Media
🔒 Premium section
13. Deep Dive: Push Notifications
🔒 Premium section
14. Deep Dive: Backups and the Key Vault
🔒 Premium section
15. Deep Dive: Spam and Abuse Without Reading Messages
🔒 Premium section
16. Deep Dive: Law and Policy
🔒 Premium section
17. Peaks and Capacity
🔒 Premium section
18. What Happens When Each Part Goes Down
🔒 Premium section
19. Bottlenecks
🔒 Premium section
20. Trade-Offs We Chose and Rejected
🔒 Premium section
21. Multi-Region
🔒 Premium section
22. In the Interview (45 and 60 Minutes)
🔒 Premium section
23. Further Reading
🔒 Premium section
Explore the Technologies
🔒 Premium section