📝 Problem Description
Design a team messaging platform like Slack or Discord. Support channels, direct messages, threads, file sharing, and real-time presence. Handle workspaces with thousands of users.
👤 Use Cases
1.
User wants to sends message to channel so that all channel members receive it
2.
User wants to starts a thread so that replies grouped under parent message
3.
User wants to reacts to message so that reaction visible to all
4.
User wants to shares a file so that file accessible in channel
✅ Functional Requirements
- •Workspaces/servers with channels
- •Public and private channels
- •Direct messages (1:1 and groups)
- •Threaded replies
- •Message reactions and emojis
- •File/image sharing
- •User presence (online/away/offline)
- •Message search
- •Notifications
⚡ Non-Functional Requirements
- •Message delivery < 100ms
- •Support 1M concurrent users
- •99.99% availability
- •Message persistence
⚠️ Constraints & Assumptions
- •Large channels (10K+ members)
- •Rich media support
- •Real-time sync across devices
📊 Capacity Estimation
👥 Users
50M users, 5M concurrent
💾 Storage
1PB (messages, files)
⚡ QPS
Messages: 100K/sec, Connections: 5M WebSocket
📐 Assumptions
- • 50M registered users
- • 5M concurrent connections
- • 100 messages per user per day
- • Average message: 500 bytes
💡 Key Concepts
CRITICAL
WebSocket Fan-out
Publish message to channel topic, all subscribers receive via WebSocket.
CRITICAL
Channel-based Pub/Sub
Each channel is a Redis pub/sub topic for real-time delivery.
HIGH
Presence Heartbeats
Clients ping every 30s; absent = offline after timeout.
MEDIUM
Message Threading
Thread replies reference parent_id; fetch thread separately.
💡 Interview Tips
- 💡Start with the WebSocket architecture for real-time messaging
- 💡Discuss presence detection and status updates
- 💡Emphasize the fan-out challenge for large channels
- 💡Be prepared to discuss message persistence and search
- 💡Know the difference between Slack (enterprise) and Discord (community)
- 💡Understand workspace/server isolation