call(back)

Design a Synchronized Live Comment Overlay

Design the comment overlay for a video product: viewers post short comments that scroll across the picture, and every viewer sees a comment at the moment in the video it refers to. Cover both cases.

  • Recorded video. A comment is attached to a playback position. Anyone watching later sees it when playback reaches that position, including after seeking.
  • Live streams. A comment should appear on other viewers' screens within about a second, in rooms that range from ten viewers to several million.

Explain the storage model, how clients receive comments, what happens in a room where thousands of comments arrive per second, and how moderation fits in.

Hints

Hint 1

The two cases share a write path but have different read paths: recorded video is a range query by playback time, live is a subscription.

Hint 2

For recorded video, bucket comments by video and time segment so the player can fetch the next segment ahead of playback.

Hint 3

A screen can show only so many comments per second. In a huge room the server should sample before fan-out, not send everything and let clients drop it.

Asked at

Similar Problems5