Durable Messaging Chat System
Design a reliable text-chat service for one-to-one and group conversations.
Problem statement
For this exercise, assume authenticated users exchange text messages in one-to-one conversations and groups, observe ordered conversation history, and reconnect from a known cursor. A client-generated key makes retries idempotent. The service must preserve accepted messages during transient dependency failures.
Treat durable send acceptance, per-device delivery progress, and per-user read progress as distinct monotonic states. For this exercise, also assume the sender sees each message as sending, received or read, and a message shows as sending from the moment it is submitted until the server confirms durable acceptance.
Choose and defend push, pull, or hybrid delivery for ordinary and large groups while accounting for offline members, slow consumers, and backpressure. Exclude voice, video, media processing, and end-to-end encryption.
What to build
- Accept an idempotent text-message send and return a stable server message identifier.
- Deliver new messages to online conversation members with per-conversation ordering.
- Page durable conversation history and resume after reconnect without unexplained gaps.
- Expose durable send acceptance, per-device delivery progress, and per-user read progress as distinct monotonic states, and show the sender each message as sending, received, or read; for this exercise, sending lasts until durable acceptance.
At scale
- Assume 8 million daily active users and 120,000 peak message sends per second.
- A conversation may contain up to 2,000 members, but most are one-to-one.
- Accepted messages must survive a process failure and normally reach online recipients within 500 milliseconds.