Design a TCP Discord-like chat server
DiscordSoftware Engineer · OnsiteLast updated
This question evaluates a candidate's skills in system design, TCP-based protocol design, real-time messaging, data modeling, persistence, session/reconnection handling, and concurrency control for backend services.
Design a Discord-like chat server that accepts multiple clients over raw TCP (e.g., test via PuTTY/telnet).
Functional requirements:
- Clients connect over TCP and can send line-based messages.
- Support slash commands:
/helpshow available commands/nick <name>set/change nickname/userslist users (at least in current room, or globally—state your choice)/quitdisconnect- Chat rooms:
- Create rooms, join rooms, and list rooms
- Messages sent to a room are broadcast to all users currently in that room
- Reconnection:
- If a client disconnects and later reconnects (identify how), they should be able to rejoin their previous rooms
- Message history:
- When a user joins a room, show the last 10 messages from that room
- Persistence:
- Data must persist across server restarts (users/rooms/membership/messages as needed)
Non-functional requirements:
- Keep scalability in mind (multiple concurrent clients; discuss how to scale beyond one process/host).
Explain your protocol, core data model, key components, and how you would handle concurrency, durability, and scaling.
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.