Problem Description
Design a Discord-like chat server that accepts multiple clients over raw TCP. The server should support line-based messages and various chat functionalities.
Functional Requirements
- Client Connectivity: Clients connect over TCP and can send line-based messages.
- Slash Commands: Support the following commands:
/help: Display available commands./nick <name>: Set or change a user's nickname./users: List users (candidate must state choice: current room or globally)./quit: Disconnect the client.
- Chat Rooms:
- Allow users to create, join, and list available rooms.
- Messages sent to a room must be broadcast to all users currently in that room.
- Reconnection: If a client disconnects and later reconnects, the system must identify the client and allow them to rejoin their previous rooms.
- Message History: When a user joins a room, they should be shown the last 10 messages from that room.
- Persistence: All critical data (users, rooms, room memberships, and messages) must persist across server restarts.
Non-Functional Requirements
- Scalability: The design must accommodate multiple concurrent clients and discuss strategies for scaling beyond a single process or host.
Design Deliverables
Candidates are expected to explain their proposed protocol, core data model, key components, and how they would handle concurrency, durability, and scaling.
AI interview prep
Core dilemma
Balancing real-time, low-latency message delivery and stateful client connections with the need for high scalability, fault tolerance, and data persistence in a distributed environment.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Problem Description
Design a Discord-like chat server that accepts multiple clients over raw TCP. The server should support line-based messages and various chat functionalities.
Functional Requirements
- Client Connectivity: Clients connect over TCP and can send line-based messages.
- Slash Commands: Support the following commands:
/help: Display available commands./nick <name>: Set or change a user's nickname./users: List users (candidate must state choice: current room or globally)./quit: Disconnect the client.
- Chat Rooms:
- Allow users to create, join, and list available rooms.
- Messages sent to a room must be broadcast to all users currently in that room.
- Reconnection: If a client disconnects and later reconnects, the system must identify the client and allow them to rejoin their previous rooms.
- Message History: When a user joins a room, they should be shown the last 10 messages from that room.
- Persistence: All critical data (users, rooms, room memberships, and messages) must persist across server restarts.
Non-Functional Requirements
- Scalability: The design must accommodate multiple concurrent clients and discuss strategies for scaling beyond a single process or host.
Design Deliverables
Candidates are expected to explain their proposed protocol, core data model, key components, and how they would handle concurrency, durability, and scaling.