Design a Live-Stream Chat System
Design low-latency chat for live broadcasts with hot-channel fanout, reconnect recovery, and moderation.
Problem statement
Design the real-time chat layer for a large video-streaming platform. Viewers join the chat channel associated with a live broadcast, publish messages, and receive new messages while the stream is active.
For this exercise, assume authenticated viewers may send at most five messages per ten seconds; moderators may remove a message or mute a viewer; clients that reconnect may request up to ten minutes of recent history; ordering is required within one channel partition but not across channels; and chat history is retained for 30 days.
Explain your assumptions and keep video delivery itself out of scope.
What to build
- A viewer can join or leave the chat channel for a live broadcast.
- An authenticated viewer can publish a chat message subject to rate limits and moderation.
- Connected viewers receive new messages for their channel with low latency.
- A reconnecting viewer can retrieve a bounded recent message window.
- A moderator can remove a message and mute an abusive viewer.
At scale
- Assume 10 million concurrent chat connections across all live broadcasts.
- A single exceptionally hot broadcast may have 1 million connected viewers.
- Assume a peak ingest rate of 200,000 messages per second globally.
- Target p95 server-to-client message delivery below 500 milliseconds for healthy connected clients.
- Retain chat messages for 30 days while keeping only ten minutes in the reconnect hot path.