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)
Variations to practise
3 min read+10 XP
Chapters used
Approach (1), Estimation (2), Blob storage and presigned URLs (11), Replication (14), Sharding (15), Polling vs WebSockets vs push (21), Message queues (22), Pub/sub (23), Idempotency (24), CDNs (26).
Try these variations
Each is a common follow-up. Answer in two minutes, then check the sketch.
- "Show 'last seen' and 'typing…'." → Presence from gateway connect/disconnect and heartbeats, published to contacts with throttling; typing indicators are fire-and-forget, never stored (Chapter 21).
- "Delete a message for everyone." → A new "delete seq 42" event in the chat; clients that have it hide it; the server drops it if still stored.
- "Search my chat history." → With end-to-end encryption, search runs on the device over its local, decrypted history.
- "Channels with millions of followers." → One-way broadcast: store once, followers pull (fan-out on read, Chapter 23), no per-follower delivery receipts.