System design case study C08 · HLS/DASH · CDN

Design a Video Streaming Platform (YouTube/Netflix-style)

Accept uploads of any size, transcode them into a ladder of formats, and stream smoothly to millions of viewers on networks ranging from fibre to a train in a tunnel.

What you'll be able to explain
  • Build a chunked, parallel transcoding pipeline
  • Explain adaptive bitrate streaming (HLS/DASH)
  • Use CDNs and pre-positioning for popular content
  • Track watch progress and views at scale
  • Contrast user-generated (YouTube) and catalogue (Netflix) platforms

Scope

Functional

  • Upload video; process into streamable formats; watch with seeking; resume where you left off.
  • View counts; recommendations and search are out of scope (briefly mentioned).

Non-functional

  • Start playback in < 2 s; rebuffering < 0.5% of watch time.
  • Uploads of up to several GB, resumable. Processing completes in minutes for typical videos.
  • 200M daily viewers.

Size

  • Uploads: 500k videos/day, average 10 minutes.
  • Each source ~1 GB; output ladder ~2× source → ~1.5 PB/day of new storage.
  • Watching: 200M viewers × 60 min/day at an average 3 Mbps → peak egress in the hundreds of Tbps. Only CDNs (including ISP-embedded caches) can serve this.

Upload and processing

CLIENTCreatorSERVICEUpload serviceresumableOBJECT STORERaw storeSERVICEWorkfloworchestratorWORKERSplitter2-10 s chunksWORKERTranscoders×1000sWORKERPackagerHLS / DASHOBJECT STORESegments storeNETWORKCDNDATABASEVideo metadatamultipartuploadedchunk × renditionREADY
Upload, split into chunks, transcode in parallel, package, publish to CDN.
  • Chunk-parallel transcoding: split the source at keyframes into short chunks and transcode each chunk × each rendition in parallel on a large worker pool (a DAG managed by a workflow engine). A 1-hour video finishes in minutes instead of hours.
  • Encoding ladder: e.g. 240p to 4K at several bitrates, H.264 for compatibility plus AV1/HEVC for efficiency. Netflix-style per-title encoding picks the ladder per video based on its complexity (cartoons need fewer bits than sports).
  • Packaging: segments (2–6 s) plus a manifest (.m3u8 for HLS, .mpd for DASH). DRM encryption for premium content.

Playback

PlayerPlayback APICDN1GET /play/v123 (auth, entitlements)2manifest URL (signed) + DRM licence info3GET master.m3u84renditions 240p … 1080p5GET 720p/seg_001.ts6bandwidth drops → switch down7GET 480p/seg_002.ts
Adaptive bitrate: the player picks each segment's quality based on measured bandwidth.

The player owns adaptation: it measures throughput and buffer level and chooses the next segment's quality. The server just serves files, which is why video scales like static content.

The 30-second summary

Say it in the interview

"Uploads are resumable to object storage. A workflow splits the video into chunks, transcodes chunk × rendition in parallel, and packages HLS/DASH segments with manifests. Playback is adaptive bitrate: the player picks segment quality while the CDN serves immutable segments, with pre-positioning for popular titles. Progress and views flow through Kafka into last-write-wins stores and aggregators."

Follow-up questions the interviewer may ask

  1. How do you speed up transcoding for long videos?
  2. How do you decide which renditions to produce?
  3. How do you protect premium content?
  4. How do you resume playback across devices?

Model answers to each of these are in the book.