Real-time chat with delivery receipts

A support tool polls for messages every few seconds. Customers now expect real-time chat with groups and read receipts.

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.

The system today: 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 has to change: 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 to ask first

Where the interviewer digs in

What a strong answer covers

Common mistakes