Design StreamChat — StreamHub's messaging layer supporting one-to-one and group chats with delivery receipts, online presence, and message history. This is a classic product design: scope first, estimate scale, then draw boxes.
Requirements
Functional requirements
- One-to-one and group messaging (up to 500 members per group).
- Real-time delivery to online users; push notification to offline users.
- Message history: fetch last N messages and paginate backward.
- Delivery and read receipts (sent ✓, delivered ✓✓, read ✓✓ blue).
- Online/offline presence indicators and typing indicators.
- Share images and links (media stored in object storage).
Non-functional requirements
- Latency: message delivery under 200 ms for online users.
- Scale: 50M DAU; 10M concurrent WebSocket connections.
- Availability: 99.9% — chat is core engagement.
- Ordering: Messages in a conversation appear in send order.
- Durability: Messages never lost once server acknowledges send.
Out of scope: Voice/video calls, end-to-end encryption, message editing (mention as future work).
Estimation
- 50M DAU × 40 messages/day = 2B messages/day ≈ 23K messages/sec average, ~70K peak.
- Avg message size: 200 bytes text + metadata ≈ 500 bytes → 2B × 500 B = 1 TB/day storage.
- 5-year retention for premium users: ~1.8 PB — requires tiered storage and archival.
- 10M concurrent WebSocket connections → ~10K connections per server × 1,000 connection servers.
Chat system (AWS)
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 4 sections
- API design
- High-level architecture
- Deep dive: cross-server message routing
- Deep dive: group message fan-out
Test yourself
Answer these before moving on — recall is what makes it stick.