Design a live video comments system
MetaSoftware Engineer · OnsiteLast updated
This problem tests your ability to design a high-throughput, real-time messaging system capable of handling sudden spikes in concurrent viewers and maintaining low latency for chat delivery.
Problem Statement
Design a live video comments system similar to those found on platforms like Facebook Live or Twitch. The system must support millions of concurrent viewers for a single broadcast while ensuring that comments are delivered to all users with minimal delay.
Functional Requirements
- Users can post comments to a live broadcast.
- Users can view a live feed of incoming comments.
- The system should handle high-write throughput (many users commenting simultaneously).
Non-Functional Requirements
- Latency: Comment delivery should be sub-500ms.
- Scalability: The system must support 100k+ concurrent viewers per broadcast.
- Reliability: Comments should be persisted eventually; occasional packet loss for live updates is acceptable.
Deliverables
- High-level architecture diagram and component interaction.
- API design (WebSocket/REST endpoints).
- Data model for storing comments.
- Strategy for handling "fan-out" to a massive audience.
- Approaches for dealing with comment moderation in real-time.
Hints
Hint 1
Consider the trade-offs between a pull-based polling mechanism and a push-based WebSocket approach for real-time delivery.
Hint 2
Think about using a message queue or a pub-sub model to decouple comment ingestion from the delivery service.
Hint 3
How can you partition the broadcast audience to avoid a single server bottleneck during the fan-out process?
Follow-up questions
- How would you handle a "celebrity broadcast" where the comment rate exceeds 10,000 messages per second?
- How would you ensure that a user who joins 5 minutes into the broadcast sees the history of comments without overloading the database?
- If you needed to implement a real-time profanity filter, where would you place this logic to minimize latency?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.