Design a Live Comments
Design live comments for a social network. While someone watches a live video or a busy post, new comments from other viewers slide in within about a second, without a refresh. Viewers can post a comment, see the latest ones the moment they open the post, and pick up where they left off after their phone drops the connection.
At peak, 20 million people are watching live posts at the same time, and they write about 20,000 comments a second. Most posts have a handful of viewers, but one big live event can hold 6 million of them, writing 6,000 comments a second. The hard part is the fan-out: every comment must reach every viewer of that post, so a hot post turns a few thousand writes into billions of deliveries, more than any phone can show or any network should carry.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Which posts get live comments?
- 2How fast must a comment appear?
- 3Must every viewer see every comment?
- 4Do comments need a strict order?
- 5What happens after a dropped connection?
- 6Replies, likes and edits?
- 7Who can comment?
- 8Is history kept?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API and connections
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Fan-out, hot posts and failures