Design a Slack-like messaging system
Company: Databricks
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Onsite
Design a Slack-like real-time team messaging system.
Requirements:
- Users can:
- Create and join workspaces.
- Create public and private channels within a workspace.
- Send messages in channels and direct messages (DMs).
- See message history and search messages by keyword.
- Messages should appear in near real-time to all online participants in a channel or DM.
- Support presence indicators (online/away) at a basic level.
- System should support:
- 10 million registered users.
- 1 million daily active users.
- Peak 200k concurrent connections.
Tasks:
1. Clarify and state any additional assumptions you need (e.g., file sharing scope, message size limits, retention policy).
2. Propose a high-level architecture:
- How clients connect (e.g., WebSockets, polling).
- Major backend services and their responsibilities (e.g., gateway, messaging service, user service, search service).
- Data storage for users, workspaces, channels, and messages.
3. Design the data model for core entities:
- Users, workspaces, channels, memberships, and messages.
- Explain how you would partition/shard message data.
4. Describe how real-time messaging works end-to-end:
- From a user sending a message to it being delivered and persisted.
- Handling fan-out to many subscribers in a busy channel.
5. Discuss scalability:
- How to handle 200k+ concurrent connections.
- Horizontal scaling strategies for message processing.
- Handling hot channels with very high message throughput.
6. Address reliability and consistency:
- Ensuring messages are not lost (at-least-once vs exactly-once semantics).
- Ordering guarantees within a channel.
7. Describe how you would implement search over message history:
- Indexing strategy.
- High-level read/write path for search.
8. Mention key trade-offs and potential future extensions (e.g., threading, reactions, file attachments).
Quick Answer: This question evaluates system design and distributed-systems competencies, focusing on real-time messaging architecture, data modeling, scalability, reliability, and search for a large-scale chat platform.