Design Slack-like chat system
DiscordSoftware Engineer · OnsiteLast updated
An onsite system-design interview question asking you to design the chat subsystem for a Slack/Discord-like app: workspaces, channels, 1:1 and group DMs, full message history, real-time updates, and edit/delete. It tests data modeling, storage and partitioning, fanout strategy, real-time WebSocket delivery, and per-conversation ordering and consistency.
Question
Design the chat subsystem for an app like Slack/Discord. State your assumptions (scale, retention, consistency needs) and propose an end-to-end architecture, then expect deep follow-ups on the trade-offs.
Product requirements
- The product has workspaces; each workspace contains channels. Users can join a workspace and view all channels they have access to (public and private channels).
- Users can send plain-text messages in any channel they are a member of, and the channel may have many members (some "announcement" channels can reach 100k+).
- Users can also have direct messages — 1:1 and small group DMs.
- Users can scroll back and read the full message history (assume no expiration / long retention).
- Users should see new messages in real time without refreshing.
- Support editing and deleting messages.
Design areas to cover (expect a deep dive on each)
- Core APIs — send message, fetch history (pagination), subscribe for real-time, edit/delete.
- Data model for workspaces, channels/conversations, membership, and messages.
- Storage choice, sharding/partitioning, and how history queries stay efficient.
- Real-time delivery (WebSocket / pub-sub) and connection/subscription management.
- Fanout strategy — write fanout vs read fanout — and the trade-offs at different channel sizes.
- Ordering and consistency guarantees (per-conversation ordering, read-your-writes) and handling edits/deletes.
- Indexing / full-text search over message history (if asked).
- Hot channels and performance bottlenecks — how you mitigate very large or very active conversations.
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.