Design One-to-One Chat
AnthropicSoftware Engineer · OnsiteLast updated
This question evaluates expertise in designing scalable, real-time one-to-one messaging systems, testing knowledge of distributed systems principles, message persistence and retrieval, delivery semantics, session and WebSocket management, ordering, retries, deduplication, and trade-offs between streaming and in-memory technologies such as Kafka and Redis. It is commonly asked to assess architectural reasoning about latency, availability, ordering guarantees and reliability within the System Design domain, and requires a mix of conceptual architectural understanding and practical implementation-level considerations.
Design a scalable one-to-one chat system.
Scope:
- Only direct one-to-one messaging is required.
- Group chat, public channels, workspace features, and threaded conversations are out of scope.
Your design should cover:
- Core user flows for sending and receiving a message.
- Message persistence and retrieval.
- Delivery when the recipient is online.
- Delivery when the recipient is offline.
- How the system detects whether a user is online.
- How client sessions and WebSocket connections are stored and managed.
- Ordering, retries, deduplication, and delivery acknowledgements.
- The tradeoffs between using Kafka and Redis in the design.
- The internal principles of Kafka that matter for this system, such as partitions, ordering, offsets, and consumer groups.
State your assumptions about scale, latency, and reliability requirements before presenting the design.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.