KatInterview

Design a Timeline-Anchored Live Reaction Stream

System DesignModel answer
HardModel answerSystem Designreal-timestreamingdistributed-systems

Last updated

Design a system that attaches viewer comments to specific moments on a video timeline, staying synchronized across live watching, replay, seeking, and reconnection.

Timeline-Anchored Live Reaction Stream

A popular streaming platform wants to add a feature where viewers can post short text reactions that appear as a floating overlay tied to a specific moment in a video. A comment posted at the two-minute mark should appear for every viewer — live or replaying — when they reach that same moment, not when it was originally submitted.

Design the backend and client protocol for this feature end-to-end.

What to cover

  • Publish and read APIs: how clients submit a comment and how they pull or receive comments
  • Timeline semantics: what timestamp anchors a comment — wall-clock time, media position, or some combination — and why the choice matters
  • Ordering guarantees: what "same order for all viewers" means in practice and what it costs
  • Real-time delivery: the fanout path from one publisher to potentially millions of concurrent viewers
  • Storage and replay: how comments are stored so a viewer who seeks to an arbitrary position gets the right comments quickly
  • Moderation and abuse controls: pre-publish filtering, post-publish removal, and per-user blocking
  • Backpressure and load shedding: what happens when comment volume spikes beyond what clients can render
  • Client synchronization: reconnect cursors, deduplication, and handling clock skew between client and server

Constraints and assumptions

  • A single live event can attract a very large concurrent audience; comment bursts during exciting moments are expected
  • Viewers may pause, seek backward or forward, lose connectivity, or join mid-stream
  • The overlay must remain usable under extreme load — rendering every accepted comment is not required
  • The same underlying design should support both live events and on-demand replay of past events

Clarifying questions a strong candidate would raise

  • Is the canonical position the server's wall-clock time, a media presentation timestamp (PTS), or an event-relative offset in seconds?
  • Do all viewers need to see comments in exactly the same order, or is approximate consistency acceptable?
  • What are the latency, geographic distribution, and retention requirements?
  • Are secondary features — reactions, replies, creator pinning, profanity filters — in scope?

Hints

Hint 1

Start by settling on what a comment's timestamp actually means. A comment anchored to a media position offset (e.g., T+92 seconds from event start) survives seeks and replay in a way that wall-clock time alone does not — nail this before touching any infrastructure.

Hint 2

The read path and the write path have very different scaling shapes. The write path is one producer per comment; the read path fans out to potentially millions of subscribers. Think about where to break that fanout — push-based pub/sub, pull-based polling with a cursor, or a hybrid — and what each costs in latency and infrastructure complexity.

Hint 3

For replay and seeking, think in time buckets. Storing comments indexed by a quantized timeline offset (e.g., per-second or per-5-second bucket) lets you answer 'give me all comments between T+90s and T+120s' with a bounded, predictable read. Consider how you'd handle a viewer who rapidly scrubs through the timeline without overwhelming storage.