SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 48
Design live comments for live video
While a live video plays, viewers type comments that scroll past for everyone else watching. A small stream has a few dozen viewers; a big event has millions on one stream, all expecting to see the chat move in real time and to see a removed comment vanish.
Requirements
- Post a comment on a live video.
- Everyone currently watching sees new comments within about 2 seconds.
- A viewer who joins or reconnects sees the most recent comments first, then the live flow.
- Comments are screened by an automatic filter, and a moderator can remove a comment so it disappears from screens that already show it.
Constraints and assumptions
- 10,000 concurrent live videos at peak with 20 million viewers in total; the largest single stream has 2 million.
- Up to 100,000 new comments per second overall; the largest stream can see 2,000 per second.
- One connection server holds about 100,000 viewer connections.
- A person can read roughly 5 to 10 comments per second on screen.
- Comments are up to 300 characters; delivery p99 within 2 seconds of posting.
Out of scope for the first sketch
The video stream itself · Reactions and like counts · Comment replay after the broadcast ends
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design live comments for live video
Finish your first sketch before answering these. Cross out freely.
- A viewer's phone drops off Wi-Fi for 20 seconds. What do they see when it reconnects?
- How does a new comment reach 2 million open connections without one server sending 2 million messages?
- The biggest stream gets 2,000 comments per second. Should every viewer receive every comment?
- A moderator removes a comment 5 seconds after it was posted. How does it disappear from screens that already show it?
- Viewers on different continents see comments in slightly different orders. Does that matter, and what order do you promise?
Compare afterwards: worked approaches and reading at sketchbook /questions/live-comments/review