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.8 How do delivery and read ticks work?
3 min read+10 XP
Figure: three acknowledgements, each moving the tick forward.
- One grey tick: the server stored the message (the ack with seq).
- Two grey ticks: every recipient device has it. In the chapter's code, Ravi's phone acking isn't enough while his laptop hasn't; two ticks appear only after both ack.
- Blue ticks: the recipient opened the chat past that message.
Efficiency:
- Acks say "up to seq N", so one ack covers many messages.
- The server forwards receipts to the sender's devices only when the combined state changes.
- Read receipts are optional for users (a privacy setting); when off, the server never sends "read" for them.
Memory code: "Stored, every device has it, the person read it."