Real-time chat with delivery receipts: a system design interview question
A support tool polls for messages every few seconds. Customers now expect real-time chat with groups and read receipts. It is a mid-level question of about 40 minutes, and it starts from a system that already works, which is how many real design interviews begin.
How do I approach the real-time chat with delivery receipts question?
To design real-time chat, keep persistent connections for delivery and a durable message store as the source of truth. Route each message to the gateway holding the recipient, order messages with per-conversation sequence numbers, make sends idempotent with client IDs, and batch receipts so groups do not flood the system.
Practise this design interview
The situation
A customer-support tool has a chat box. The browser asks the server for new messages every five seconds, and messages are rows in one SQL table. It works for a few hundred concurrent users.
What you are asked to design
Rebuild it as real-time chat for 2 million concurrent users: one-to-one and group conversations, messages that arrive in order, sent and delivered and read receipts, and no lost messages when someone is offline or reconnects.
Questions worth asking first
How large can a group be, and is there a message size limit?
Do messages need end-to-end encryption, or is server-side storage fine?
How long do we keep history, and does it sync across a user's devices?
What ordering guarantee do we need: per conversation, or global?
Where interviewers dig
Persistent connections (WebSockets) and routing a message to the server that holds the recipient's connection.
Ordering and idempotency: sequence numbers per conversation and retries.
Offline delivery and receipts without a write storm.
What a strong answer covers
Uses persistent connections for delivery and keeps a durable store as the source of truth, so a dropped connection never loses a message.
Handles routing: a presence or session registry that says which gateway server holds each user, and a pub/sub layer between gateways.
Orders messages with a per-conversation sequence number and makes sends idempotent with a client-generated ID so retries do not duplicate.
Explains receipts as small events batched on the client, and group fan-out limits for large groups.
Traps that cost points
Relying on timestamps for ordering across devices with different clocks.
Treating the connection as the store: a message only in memory on a gateway is lost when it restarts.
Sending a read receipt per message per person in a large group.
How the practice works here
It works on a laptop or desktop, not on a phone: the canvas and the interviewer's view of your drawing need the screen space.
You talk with the interviewer by voice, and the canvas already shows the company's system as it is today. You extend it, and the interviewer sees what you draw. A button pauses your microphone when you want to think or sketch in silence; the interviewer waits.
When the time is up you get a report: a hire or no-hire call for the level, ratings for problem navigation, solution design, technical depth and communication with a quote from your own answer for each, what to fix, and the points a strong answer covered that yours did not. Your first interview on giveinterview, of any kind, is free, and every interview report is free. After that a design interview costs credits at the same per-minute rate as a role interview, and playing duels earns credits you can spend on it.
Frequently asked questions
How long is this design interview?
About 40 minutes, the length of a typical mid-level design round.
Can I do it on my phone?
No. System design practice needs a computer screen for the canvas, so it is for laptops and desktops only.
Do I have to draw?
Yes. The canvas starts with the current system and the interviewer sees what you add, as at a whiteboard. You can pause your microphone to sketch and explain afterwards.
Is it free?
Your first interview on giveinterview, of any kind, is free, and every interview report is free. After that a design interview costs credits at the same per-minute rate as a role interview, and playing duels earns credits you can spend on it.
Keep reading
- Short links with click analytics: a system design interview question
- A rate limiter for a public API: a system design interview question
- A news feed that stays fast at 10 million users: a system design interview question
- A reliable notification system: a system design interview question
- Selling tickets without selling a seat twice: a system design interview question
- Matching riders with nearby drivers: a system design interview question
- A payments ledger you can trust: a system design interview question
- Practice interview online, with an interviewer that answers back
- Company interview guidesRounds and questions by company