Design a One-to-One Chat System
Company: Temporal
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
Design a real-time one-to-one chat system.
Requirements:
- Registered users must authenticate before connecting.
- After authentication, clients keep a persistent connection such as a WebSocket to receive messages in real time.
- Support sending text messages between two users.
- Persist chat history and support delivery to offline users.
- Minimize message loss and duplicates, and preserve per-conversation ordering as much as practical.
- The system should scale horizontally.
Describe the backend architecture, key services, data model, and end-to-end message flow. Also explain:
- how authentication and session establishment work,
- how connections are routed to the correct server,
- how online presence is tracked,
- where a message broker such as Kafka would or would not fit,
- what consumer latency you would expect from Kafka in a typical production setup,
- and how Kafka differs from Redis pub/sub or Redis Streams for this use case.
Quick Answer: This question evaluates a candidate's ability to design scalable, real-time backend architectures for one-to-one messaging, covering competencies in distributed systems, authentication and session management, message delivery semantics, persistence, and operational trade-offs like ordering, fault tolerance, and scalability.