Design a system that supports real-time comments for a live video stream.
Core user experience
-
Viewers watching the same live stream should see new comments appear in near real-time.
-
Users can post comments; everyone watching should receive them quickly.
-
Comments are ordered in a sensible way (define your ordering semantics).
Functional requirements
-
Post a comment to a specific live stream.
-
Fetch recent comments when a viewer joins (initial load + pagination/scrollback).
-
Real-time delivery of new comments to connected viewers.
-
Basic moderation support (e.g., remove a comment; block a user; optionally profanity/spam filtering).
Non-functional requirements
-
High fan-out: a single stream can have very large concurrent audiences.
-
Low latency for real-time delivery (define a target, e.g., p95 < 1s).
-
Reliability: comments should not be silently lost; define durability/consistency tradeoffs.
-
Handle abuse: rate limiting, spam, and reconnect storms.
What to cover
-
APIs (HTTP/WebSocket) and data model.
-
High-level architecture and key components.
-
Scaling strategy (partitioning/sharding, fan-out model).
-
Consistency/order guarantees and how you implement them.
-
Storage, caching, and retention.
-
Moderation and deletion propagation.
-
Key metrics and failure modes.