Design a Chat System
A full case study of a WhatsApp-style messenger, covering WebSocket connections, message ordering, delivery guarantees, offline users and presence.
Requirements
A chat system lets users send messages to one person or a group and see them arrive in real time.
Functional:
- One-to-one and group chat (up to a few hundred members).
- Message history, available on a new device.
- Delivery to offline users when they return.
- Online or last-seen status, called presence.
- Text first; media goes through object storage.
Non-functional:
- Low latency, a few hundred milliseconds end to end.
- Ordering: messages in one conversation appear in the same order for everyone.
- No lost messages; duplicates are hidden from users.
- Stays up when a server dies.
1 of 11