KatInterview

Real-Time Chat Delivery for Live Broadcasts

System DesignModel answer
MediumModel answerSystem Designreal-timepub-subwebsockets

Last updated

Design a low-latency comment system that fans out viewer messages to millions of concurrent watchers during a live video stream.

Real-Time Chat Delivery for Live Broadcasts

You are designing the chat feature for a live video streaming platform. During a broadcast, any viewer can send a short text message that all other viewers should see within a second or two.

What you need to support:

  • Viewers send chat messages; every other viewer on that stream receives them quickly.
  • A single popular broadcast can attract millions of simultaneous viewers.
  • Broadcasters and moderators can remove or flag messages; removed messages must disappear for everyone.
  • A viewer who joins mid-stream should see a recent backlog of messages.
  • The system must enforce per-user send limits and a broadcaster-controlled "slow mode."
  • Messages should appear in roughly chronological order.

Out of scope: advanced ML-based auto-moderation, full broadcaster dashboard tooling.

What is expected in your answer:

  1. Clarify requirements and estimate scale — writes, reads, and fanout numbers.
  2. Define a minimal API (send, fetch history, delete, flag, real-time channel).
  3. Sketch a data model with justification for your storage choices.
  4. Draw the high-level architecture, covering the write path and the live delivery path.
  5. Deep-dive at least three of the following: fanout strategy for hot streams, message ordering, moderation propagation, rate limiting, reconnect and replay.
  6. Call out trade-offs explicitly wherever you make a design choice.

Hints

Hint 1

Start with the math: figure out the write rate, then the fanout rate. The two numbers are very different and point at where the real problem lives.

Hint 2

Think about what 'delivery' actually means at scale — you don't need one connection per viewer in your core pub/sub layer. What intermediate layer eliminates the N² problem?

Hint 3

For a hot stream with thousands of messages per minute, no human can read that fast anyway. What does that unlock in terms of what you actually have to deliver to each viewer?