← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 048 · Messaging and event-driven systems

Design Live Comments

Medium 50 min

A streaming platform shows a live comment feed beside each broadcast. A big football match can draw 1 million concurrent viewers on one stream, who post up to 5,000 comments per second at moments like a goal. Every viewer should see new comments within 2 seconds of posting. Nobody can read 5,000 comments a second, so the feed may sample comments when traffic is heavy, but a viewer must always see their own comment. Comments containing hate speech or spam must be removed before most viewers see them, and moderators need to delete a comment for everyone instantly.

Functional requirements

  • Post a comment to a live stream
  • Deliver new comments to every viewer of that stream in real time
  • Filter spam and abusive comments automatically before display
  • Let moderators delete comments and mute users, taking effect for all viewers
  • Load the most recent comments when a viewer joins

Non-functional requirements

  • New comments reach viewers within 2 seconds at p95
  • Posting a comment responds in under 300 ms
  • Fan-out scales to 1 million viewers on one stream without overloading any single server
  • Losing a small number of comments in a failure is acceptable; losing the whole feed is not

Constraints and scale

  • 1 million concurrent viewers on the largest stream, 5 million across all streams
  • Up to 5,000 comments per second on one stream at peak
  • About 20,000 requests per second across posting, joining and moderation

You will practise

  • Fan out messages through pub/sub to a tier of connection servers
  • Reduce fan-out cost with batching and sampling
  • Place moderation on the path without blocking delivery for long
Show 3 hints
  1. One million connections cannot sit on one server. How does a comment reach all the servers that hold viewers of that stream?
  2. Sending 5,000 messages per second to every phone is wasteful. What could each connection server do instead?
  3. How fast must the abuse filter be if it sits before delivery?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • The abuse classifier slows to 3 secondsDuring the match a new model version is deployed and its latency jumps from 30 ms to 3 seconds. Comments stop appearing and posting requests start timing out.

Run them from the workspace once your design is in place.