Skip to the guide

Design live comments (like Facebook Live or YouTube Live)

IntermediateCase study12 pages

People watching a live video type comments, and everyone else watching sees them scroll past beside the video within a second or two. It's the big screen at a stadium showing messages the crowd texts in: thousands send, and the screen only ever shows a few.

It's also asked as "design Twitch chat" or "design live reactions". Its closest case study is Chat, which sends every message to a few people, where this sends a few messages to a crowd. Interviewers like it because the writes are small and the fan-out is huge: one video with 200,000 viewers turns each comment into 200,000 deliveries. The contract for the events comes from Real-time features in the API, and this page continues its live-video numbers.

Below is a full mock interview following the seven steps of the framework. You're the candidate: at each Guess before you read on, stop and answer first.

Step 1 · Clarify the features and cut the scope

Minutes 0–5 · How this step works

Interviewer: Design live comments for live videos, like Facebook Live or YouTube Live.

You: A few questions first. Must every viewer see every comment, or can a busy stream show a selection?

Interviewer: Nobody reads hundreds a second, so a selection is fine. But every comment is kept and readable afterwards, beside the replay.

You: Do we show how many people are watching, and likes?

Interviewer: Both, roughly.

You: Who comments, and what can creators control?

Interviewer: Signed-in users comment, and anyone watching can read. Creators delete comments and block people, and a filter catches obvious spam.

You: Then I'll cover posting, the live stream of comments with a sample on busy videos, viewer and like counts, deletes and blocks, and the full history for replays. Out: the video pipeline, paid highlighted comments and ranking by friends. OK?

Interviewer: Good.

Each answer shapes the design: a selection lets the live path drop comments that storage keeps, and deletes need an event that chases a comment already on screens.

Step 2 · Non-functional requirements

Minutes 5–8 · How this step works

You: Say 10 million people watch at peak across about half a million live videos, and about 4 million on average. Most videos have a handful of viewers; a busy one has 200,000 and a viral one a million. A comment should reach other viewers' screens within 2 seconds for 99% of comments, and posting should answer within 200 ms at p99, measured at our servers. Posting and watching comments are 99.9% available, about 43 minutes a month, and the video never waits on them. An accepted comment is never lost. The commenter sees hers at once, and a deleted comment leaves every screen within about 5 seconds.