0%
System Requirements
Functional Requirements
Capacity Estimation
Top-Level Assumptions
API Design
Connection Establishment
Database Design
Message Store (per-device delivery queues)
High Level Design
The Eight Components
Request Flows
Flow 1: First-Contact X3DH Handshake
Detailed Component Design
Double Ratchet State Machine
Trade-offs and Tech Choices
Failure Scenarios and Bottlenecks
Future Improvements
Frequently asked questions
How does WhatsApp deliver messages to offline users?
How does end-to-end encryption change the design?
Why encrypt per device instead of per user?
How are group messages encrypted efficiently?
How many connections does one server hold?
In short: with end-to-end encryption, the server can't read messages, so it routes encrypted blobs it never opens. Each device keeps a long-lived connection to a connection server. A stateless routing layer looks up where each recipient device is connected and forwards a separate ciphertext per device. Messages for offline devices wait in per-device delivery queues. Clients encrypt with the Signal protocol: X3DH to start a session, the Double Ratchet for one-to-one chats, and sender keys for groups. The server holds only public keys and metadata.
Premium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockPremium content
UnlockThe routing layer writes each undelivered ciphertext to that device's queue in the message store. The device drains its queue when it reconnects, then sends a delivery receipt.
The server can't search, index or filter content, so abuse detection works on metadata and user reports. Backups and multi-device sync also have to be encrypted on the client.
With per-device keys, one compromised device puts only that device's history at risk, and a newly added device starts fresh sessions. A shared per-user key would expose every device. The cost is one ciphertext per device, but most users have only one or two.
With sender keys. Each member encrypts once with their own sender key, which was shared with the group in advance. The key rotates whenever someone leaves.
About 100,000 long-lived connections per server, so a 2 billion user service needs roughly 10,000 connection servers.
Reading a solution is not the same as producing one under interview pressure. Design it on the whiteboard and get scored feedback.
The building blocks this design relies on, each explained in its own lesson.
0%
System Requirements
Functional Requirements
Capacity Estimation
Top-Level Assumptions
API Design
Connection Establishment
Database Design
Message Store (per-device delivery queues)
High Level Design
The Eight Components
Request Flows
Flow 1: First-Contact X3DH Handshake
Detailed Component Design
Double Ratchet State Machine
Trade-offs and Tech Choices
Failure Scenarios and Bottlenecks
Future Improvements
Frequently asked questions
How does WhatsApp deliver messages to offline users?
How does end-to-end encryption change the design?
Why encrypt per device instead of per user?
How are group messages encrypted efficiently?
How many connections does one server hold?