5. Design a Chat System
Send durable messages, reconnect devices and explain ordering and delivery receipts.
The brief
Design private one-to-one and small-group chat with multiple devices per user. Explain message acceptance, durable history, online delivery and reconnect synchronization. State what ordering and read receipts mean when two devices send concurrently or go offline.
- Support 1 million concurrently connected users and 50,000 new messages/second at peak.
- Groups contain at most 100 users, and a device may be offline for seven days.
- Clients retry after lost acknowledgements; attachments are referenced files rather than inline message bytes.
Constraints
- Online delivery latency≤ 500 milliseconds
- Declare p95 acceptance-to-recipient delay for connected users in a healthy region.
- Acknowledgement contract
- A sender must know when a message is durably accepted versus merely written to a socket.
- Private history
- Authorize delivery and history reads using a stated group-membership policy.
What to cover
- 01
Messaging protocol
Define send IDs, acknowledgements, conversation ordering and receipt states.
- 02
Storage and connection routing
Show history ownership, live connections and attachment access.
- 03
Reconnect walkthrough
Trace offline catch-up, duplicates and two devices sending concurrently.
- 04
Capacity and failure
Estimate connection and message load; explain gateway loss and group fan-out.
Worked designs
Explore the architecture and decisions, then build on an example with Coach.
Review rubric
AI feedback uses these criteria. Scores are practice feedback.
Message semantics
Ordering, durable acknowledgement and retries are explicit.
Device convergence
Reconnect and receipts converge without losing accepted messages.
Privacy and membership
History, fan-out and attachments respect access rules.
Serving capacity
Connections, fan-out and gateway recovery have supported estimates.
Discussion
Share an approach, ask a question, or tag @Coach.
Loading discussion…