Question presented to candidate:
"Design a chat app like WhatsApp or Messenger: one-to-one and group conversations, messages delivered in real time when the other person is online, nothing lost when they are offline, and history synced across a user's devices."
What a strong answer should cover:
Requirements and capacity: messages per second, storage per day, concurrent connections and how many gateway servers they need
Persistent connections (WebSocket) to a gateway tier, a session registry mapping users to gateways, and routing a message to the recipient gateway; the message is stored before it is acknowledged
Per-conversation sequence numbers for ordering, client message ids so a retried send is stored once, and sync from the last sequence seen for offline users and new devices
Gap detection on the client (held messages, gap timer, fetch the missing range) and push notifications for offline users
Storage keyed by conversation and sequence in a wide-column store, group fan-out per gateway rather than per member, and what breaks at 10x (very large groups, hot conversations, reconnect storms)
Clarifying questions expected:
One-to-one only, or groups too? How large can a group be?
Must history be stored on the server and synced to many devices, or only relayed (store-and-forward until delivered)?
Which receipts are needed: sent, delivered, read? Typing indicators and presence?
Code / implementation expected: Optional โ a simulation of the delivery protocol: sequence numbers, a lost ack and a deduplicated retry, offline sync, a delayed and a dropped message repaired by the client; the example does that.
chat
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers preparing for a system design round. You know HTTP and what a database is; persistent connections, sequencing and sync are explained from scratch.
Difficulty: Hard
Verified with: Node 22.22 and Python 3.12 (both print identical output). Product facts are cited inline, checked in October 2026.
How to read this doc: Plain language first, then ๐ Interview term: callouts with the vocabulary an interviewer expects. The capacity numbers and the delivery trace come from the example program, quoted in full in the Verified section. Connection-level topics have their own pages: WebSockets vs polling vs SSE, presence and sticky sessions and [scaling to 1M WebSocket connections](/intervie
The solution is hidden so you can try first
15 min read ยท 16 sections
4
Read the code
Chat delivery: per-conversation sequence numbers, idempotent retries, offline sync, gap repair and per-gateway group fan-out