System Design Visualized
Chapter 14 · about 60 minutes

Design YouTube

YouTube looks simple: creators upload videos, viewers click play. Behind it are huge numbers: in 2020 it had 2 billion monthly active users, 5 billion videos watched per day, and 500 hours of video uploaded every minute. This chapter designs a video-sharing platform. The same ideas apply to Netflix, Hulu and others.

Start the interactive chapter
  1. 14.1Requirements and estimationUpload videos fast; smooth streaming; ability to change video quality Mobile apps, web browsers and smart TVs; international users; most…
  2. 14.2High-level design: the video uploading flowAt the highest level there are three parts: the client, a CDN that stores and streams videos, and API servers for everything else (feed…
  3. 14.3Video streaming and adaptive bitrateDownloading means copying the whole video before watching. Streaming means your device receives the video continuously and plays it…
  4. 14.4Video transcoding and the DAG modelA recorded video is in a raw format that takes huge space: an hour of HD video at 60 frames per second can take up hundreds of GB.…
  5. 14.5Video transcoding architecturePreprocessor: (1) splits the video into Group of Pictures (GOP) chunks, independently playable units of a few seconds (old clients that…
  6. 14.6Optimizations: speed, safety and cost⚡ Speed Parallelize uploading: the client splits the video into GOP-aligned chunks and uploads them in parallel. A failed chunk can be…
  7. 14.7Error handling and wrap upTwo kinds of errors: Recoverable: e.g. a video segment fails to transcode. Retry a few times; if it keeps failing and can't be recovered,…