38. Design a Chat App (WhatsApp)
1
The interview prompt2
38.1 What do you ask first?3
38.2 How big is this, really?4
38.3 What are the doors?5
38.4 What do we store?6
38.5 What does the whole system look like?7
38.6 How does the WebSocket gateway work?8
38.7 How do message IDs and ordering work?9
38.8 How do delivery and read ticks work?10
38.9 How does offline delivery work?11
38.10 How does group chat work?12
38.11 How does media work?13
38.12 What would you say in the last five minutes?14
Score yourself15
Variations to practise16
Sources17
Code lab38. Design a Chat App (WhatsApp)
38.1 What do you ask first?
3 min read+10 XP
Step 1: Requirements (5 minutes)
| Letter | Candidate asks | Interviewer answers |
|---|---|---|
| Scope | "One-to-one and groups? How big can groups be? Media? Multiple devices per user? End-to-end encryption? Calls?" | "Both. Groups up to about a thousand. Photos and videos. Phone plus a laptop. Yes, end-to-end encrypted. Skip calls." |
| Count | "How many users and messages?" | "500 million daily users, about 40 messages each a day." |
| Access pattern | "How many are online at once?" | "Up to about 200 million connected at peak." |
| Latency | "How fast should a message arrive?" | "Under a second when both are online." |
| Exactness | "Can messages be lost, duplicated or reordered?" | "None of those. Order matters within a chat." |
Agreed requirements:
- Functional (verbs): send and receive one-to-one and group messages; show sent, delivered and read ticks; deliver messages that arrived while a device was offline; sync across a user's devices; share photos and videos.
- Non-functional (adjectives): real-time (under a second online), reliable (never lost), exactly once as seen by users (no duplicates), ordered per chat, private (end-to-end encrypted), highly available, scaling to hundreds of millions of open connections.
Interviewer pushback:
- "Ordered globally?" → Only within a chat. Two different chats have no meaningful order between them, and global ordering would need one coordinator for everything.
Memory code: "Ask about order, duplicates, offline, and how many are connected."