System Design Masterclass
Social Mediareal-timewebsocketspub-subfan-outstreamingintermediate

Design Live Comments Feature

Design real-time live comments like Facebook Live or YouTube Live

100K+ concurrent viewers per stream|Similar to Facebook, YouTube, Twitch, TikTok, Instagram|45 min read

Summary

Live comments enable real-time interaction during live streams, showing comments to all viewers within seconds. The core challenge is delivering messages to hundreds of thousands of concurrent viewers while maintaining order, handling viral streams, and keeping latency under 2 seconds. This is asked at Facebook, YouTube, Twitch, and streaming companies.

Key Takeaways

Core Problem

This is a real-time fan-out problem. One comment must be delivered to potentially millions of viewers within seconds.

The Hard Part

A viral stream with 500K viewers means one comment triggers 500K push operations. This creates a hot partition problem.

Scaling Axis

Scale by stream ID. Each stream is independent - partition comment handlers by stream, not by user.

The Question: Design a live comments system for a live streaming platform. When someone comments on a live stream, all viewers should see it in real-time.

Core Requirements: - Real-time delivery: Comments appear within 1-2 seconds for all viewers - Ordering: Comments appear in the same order for all viewers - Scale: Support streams with 100K+ concurrent viewers - Reliability: No lost comments during normal operation

What to say first

This is a real-time fan-out problem. Let me clarify the scale, consistency requirements, and what happens during viral moments before designing.

What interviewers are testing: - Do you understand WebSocket vs polling vs SSE tradeoffs? - Can you handle the hot partition problem (viral streams)? - Do you know pub/sub patterns? - Can you reason about ordering and consistency in distributed systems?

Premium Content

Sign in to access this content or upgrade for full access.