Design Twitch

Hard45 min
1 / 30
understanding7 min read

Problem Statement and Live Streaming Context

How Problem Statement and Live Streaming Context (understanding) informs Twitch architecture and interviewer depth.

Problem Statement and Live Streaming Context

Twitch is a live interactive broadcast platform: one creator can go live to millions of viewers while thousands of messages per second flow through the same channel. Unlike VOD, there is no finished file to cache ahead of time—every second of video and chat is produced in real time.

Interviewers probe whether you understand glass-to-glass latency (camera → encoder → CDN → player), hot-channel skew (0.1% of streams hold most CCU), and social monetization (subs, bits, raids) that must not block playback.

StakeholderPrimary painArchitectural lever
BroadcasterStable ingest, instant "live" badgeRegional RTMP/WebRTC ingest + health checks
ViewerLow delay, smooth ABRLL-HLS (~2s parts) + CDN edge
Trust & SafetySpam, hate raidsAsync moderation bus off chat Kafka topic

Anchor scale verbally: ~35M DAU, ~6.5M peak platform CCU, single esports finals channels above 500K CCU, chat bursts beyond 100K msgs/sec on mega-events.

javaOne Dark Pro
1public final class IngestSession {
2 private final String channelId;
3 private final String streamKey;
4 private volatile long sequence;
5
6 public IngestSession(String channelId, String streamKey) {
7 this.channelId = channelId;
8 this.streamKey = streamKey;
9 }
10
11 public long nextChunkSequence() {
12 return ++sequence;
13 }
14}
pythonOne Dark Pro
1from dataclasses import dataclass
2
3@dataclass(frozen=True)
4class ChatEnvelope:
5 channel_id: str
6 user_id: str
7 body: str
8 server_seq: int
9
10def is_spam_burst(rate_per_sec: float, ceiling: float = 25.0) -> bool:
11 return rate_per_sec > ceiling
typescriptOne Dark Pro
1interface PlaybackTicket {
2 channelId: string;
3 rendition: "1080p60" | "720p60" | "480p30";
4 edgePop: string;
5 expiresAtMs: number;
6}
7
8export function isTicketValid(ticket: PlaybackTicket, nowMs: number): boolean {
9 return nowMs < ticket.expiresAtMs;
10}

Close this section by stating you will size ingest Mbps, transcode fleet, CDN egress, and chat gateway pools separately—never as one generic "streaming service."

Why interviewers care

Twitch interviews reward crisp scope, explicit trade-offs, and failure stories—not generic microservice diagrams.

Interview checkpoint

Name one failure story for Problem Statement and Live Streaming Context that proves you understand real outages, not happy-path diagrams.

Key Highlights

  • Live + chat are separate failure domains
  • Quantify CCU before naming services
  • Hot channels need shield + dedicated transcode
Interview tip
State numeric assumptions before drawing boxes.
Mention this
Calling out hot-channel isolation and chat backpressure shows production awareness.

Section Rescue Kit

Buzzwords to use:

LL-HLSOrigin shield

Safe statements:

  • "I would separate chat fan-out from video ingest before optimizing either path."
  • "Let me quantify msgs/sec per channel before picking IRC vs custom gateway."
Design Twitch - System Design | WinJob | WinJob