System design prompts · Design
Design a chat app like WhatsApp
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Design a messaging app like WhatsApp: one-to-one chats and groups, online status, and the delivered and read ticks.
Then
Follow-ups the interviewer asks next
- What's in scope: groups, media, calls, end-to-end encryption?
- How does a message get from my phone to yours when you're online, and when you're offline?
- How do you keep messages in order inside one chat?
- Show me the data model for messages and how you shard it.
- Say 50 crore daily users send 40 messages each a day. How many messages a second, and how many open connections?
- A chat server holding 1 lakh connections crashes. What happens to those users and to messages in flight?
- A group has 1,000 members. How do you fan out one message?
- How do delivered and read ticks work without flooding the server?
- Where do photos and videos fit in?
The answer
What a strong answer covers
- Long-lived connections (WebSocket, or a light protocol over TCP) to gateway servers, and a session registry (user to gateway) in Redis.
- Send path: the phone sends with a client message id; the chat service writes it durably and gives it a sequence number per conversation; it looks up the receiver's gateway and pushes it. If the receiver is offline, it waits in their inbox and a push notification goes out.
- Order by the server's per-conversation sequence, never the phone's clock. Dedupe retries by client message id.
- Storage: a wide-column store (Cassandra, ScyllaDB, HBase) partitioned by conversation id and sorted by sequence. Some products delete from the server after delivery; others keep history.
- Numbers: 50 crore × 40 is 2,000 crore (20 billion) messages a day, about 2.3 lakh a second on average and several times that at peak. Tens of crores of open connections means thousands of gateway servers.
- Failure: the phone reconnects with backoff to another gateway, sends the last sequence it has, and the server replays the gap. A message is acknowledged only after the durable write.
- Groups: fan-out on write for small groups; for big groups, store once and fan out from the member list through a queue.
- Ticks: batched acks; "read up to sequence N" per conversation instead of one event per message.
- Media: upload to object storage with a pre-signed URL, send only the reference, download through a CDN.
- Presence: heartbeats with a TTL, sent only to contacts who have that chat open.
The red pen
Common traps
Avoid:phones polling the server every second; ordering by the phone's clock; one big relational messages table with no partitioning plan; storing media in the database.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.