V
← Back to System Design Showcase

📹 Design Facebook Live Comments & Reactions

10M+ Viewers • 100k Comments/s • 2M Reactions/s • Adaptive Sampling • Cassandra VOD

High-scale interactive live streaming architecture: Client bi-directional WebSockets, low-latency AI toxicity shield (<15ms), stream-partitioned Kafka buffers, monotonic video offset sequencer, priority-weighted adaptive sampling (defeating the celebrity stream thundering herd), Redis 1-second reaction delta aggregation, and time-bucketed Cassandra VOD replay.

Stream Scale:
Live Viewers
5.2Mviewers
● 120 WebSocket Nodes
Ingestion Velocity
48.5kcomments/s
Kafka stream buffer
Client Delivery Rate
25/s/sec /viewer
Human eye reading cap
1-Second Reactions Delta
184.2kreacts/s
● Sharded Redis Compaction
VOD Playback Sync
< 20msprecision
5-Min Cassandra Bucket
Architecture Canvas(Click any component node to inspect Hello Interview deep dive)
Viewers & Edge
AI Safety Shield
Kafka & Sequencer
Adaptive Fanout
Cassandra VOD
CLIENTS & BROADCASTERINGRESS & SAFETY SHIELDKAFKA & SEQUENCINGADAPTIVE SAMPLING & WEBSOCKET FANOUTSTORAGE & VOD REPLAYLive Viewer ClientiOS • Android • React WebVideo Player + WebSocket10M+ Concurrent ViewersBroadcaster PortalHost & Creator DashboardDedicated VIP Q&A Feed1-Click Pin & Mod ToolsAPI Gateway & EnvoyTLS Termination & AuthPer-User Token BucketMax 1 Comment / 3sAI Moderation ShieldToxicity & Spam ClassifierTrie Regex + ONNX BERT< 15ms Latency SLAReaction AggregatorSharded Redis In-Memory2M/s Heart & Like Taps1-Sec Delta FlushesKafka Buffer BusPartitioned by stream_idStrict Stream Ordering100k Comments/s Peak2-Hour Buffer RetentionTimestamp SequencerMonotonic Offset Stampervideo_playback_offset_msAuthor Badge EnrichmentDual-Path DispatcherAdaptive SamplerCelebrity Stream ShieldVIP / Friend 100% PassReservoir Sampling 25/sHuman Eye Reading CapRedis Streams Pub/SubStream Broadcast Meshlive:stream:{id}:commentsSub-5ms Fanout MeshWebSocket Gateways10M+ Duplex SocketsGo epoll / kqueue fleet50k-100k Sockets / NodeBinary Protobuf Frames< 10ms Client DeliveryCassandra VOD ReplayTime-Bucketed Tables((stream_id, bucket), offset)5-Minute Chunk PartitionsSequential Range ScansZero Hot Partition LagS3 Cold ParquetSnappy-Compressed ArchivalPost-Stream VOD Export85% Storage Cost Savings
📋

Core Requirements & Scope

Functional Requirements
  • 1. Post Live Comment: Viewers can write and submit comments during a live video stream.
  • 2. Real-Time Live Feed: Active viewers receive a flowing live stream of comments and reaction animations with < 500ms latency.
  • 3. Video Replay Sync (VOD): Recorded streams replay comments and reactions at the exact second they were originally posted.
  • 4. Celebrity Stream Throttling: During massive comment floods (100k/s), dynamically sample and rank comments down to 25/s per viewer.
Non-Functional Requirements & SLA
  • 1. Ultra-Low Latency: P95 delivery latency < 500ms end-to-end.
  • 2. High Availability: 99.99% uptime; comment pipeline degradation must never interrupt video playback.
  • 3. Extreme Asymmetry Handling: Seamlessly scale from 10 viewers on a friend's stream to 10M viewers on a celebrity broadcast.
  • 4. Durability & Consistency: 100% of non-spam comments persisted to Cassandra for historical replay and audit.
Out of Scope
  • RTMP / WebRTC / HLS video transcoding and CDN edge distribution
  • Tipping, super-chats, and digital gift payment processing
  • Deep multi-level nested reply comment threads (flat stream only)
Source: Hello Interview System Design GuideScale: 10M+ Concurrent Viewers
🎯

What is Expected at Each Level?

Mid-Level (L4 / IC4)Core Real-Time Architecture

Chooses WebSockets over HTTP polling for live comments, designs basic pub/sub fanout to WebSocket connection servers, and stores comments in Cassandra with stream_id partitioning.

Senior (L5 / IC5)The Celebrity Stream & Hot Partitions

Identifies the "Celebrity Stream" problem (100k comments/s flooding mobile screens), designs priority-weighted adaptive sampling (bypassing VIPs/friends), solves reaction storms (aggregating 2M/s reactions into 1s delta vectors), and designs time-bucketed Cassandra partition keys for smooth VOD replay.

Staff+ (L6 / IC6+)10M Viewer Edge Scaling & Fault Domain

Architects 10M+ WebSocket connection management with Go/Rust epoll and binary Protobuf, mitigates broadcast mesh network saturations via hierarchical regional edge hubs, isolates live comment failures from CDN video streaming playback, and designs automated cold Parquet tiering.

Interview Standard: Senior / Staff Expectations< 500ms Global Latency

Adaptive Sampler & Priority Ranker

Role & Overview

Intelligent rate-limiter that protects viewers and WebSocket gateways when comment volume exceeds human reading limits. Dynamically downsamples 50k–100k comments/s to a readable 25 comments/s.

Architecture Implementation

1. For low-traffic streams (< 50 comments/s): 100% of comments pass through untouched. 2. For viral celebrity streams: Enforces a multi-tier priority sampling algorithm: - Tier 1 (VIP / Broadcaster / Friends): 100% bypass rate. - Tier 2 (Verified / Top Fans): 80% pass rate. - Tier 3 (General Audience): Reservoir-sampled down to fit the 25/s window. 3. Employs sentiment & diversity scoring to ensure the stream does not repeat identical emojis.

The Celebrity Stream Sampling Problem
❌ Bad Solution: Push All 100k Comments/sec to All 10M Viewers: 10M * 100k = 1 TRILLION messages/sec across network! Entire infrastructure collapses instantly.
⚠️ Good Solution: Random Uniform Drop (Drop 99.9% of messages): Safe network load, but drops comments from the broadcaster's mother, close friends, and verified accounts.
⭐ Great Solution: Priority-Weighted Reservoir Sampler: Priority score = VIP_flag*100 + Friend_flag*50 + Verified_flag*20 + Length_score. Guarantees meaningful comments survive while capping stream at 25/sec!
Specification & Snippet
// Priority Sampling Logic
func ShouldDeliver(comment *Comment, currentQPS int) bool {
    if currentQPS <= 30 {
        return true // No downsampling needed
    }
    if comment.IsVIP || comment.IsFriendOfBroadcaster {
        return true // Always deliver VIP & Friends
    }
    // Probabilistic reservoir sampling for general viewers
    threshold := 25.0 / float64(currentQPS)
    return rand.Float64() < threshold
}