litmus

Open this on a laptop

The canvas needs room: requirements on one side, live feedback on the other. Any screen 1024px or wider works.

Design YouTube

hard

Take big video uploads, convert them for every screen and connection, and play them smoothly to viewers everywhere.

Browse all problems

The problem

Build a video site like YouTube. Anyone uploads a video, and anyone can watch it on a phone, a laptop or a TV.

Watching far outnumbers uploading: about 50 plays for every upload. Uploads are rare but huge (about 300 MB each), and every play sends a big file out, so this design is mostly about moving bytes.

What must never break is playback. A video that keeps stopping to load loses its viewer.

What it must do

  • Upload. Take a video of up to 1 GB. Big files skip your servers: the App server hands out a signed link (a pre-signed URL) and the phone sends the file to storage in pieces, so a dropped connection only costs one piece.
  • Transcode. Convert each upload into several sizes and formats, cut into pieces a few seconds long. The work is a plan of tasks (a DAG): picture, sound, thumbnail and watermark run side by side on many workers.
  • Stream. Send the pieces to the player from a CDN near the viewer. Streaming formats such as HLS and MPEG-DASH let the player switch size as the connection speeds up or slows down.

What you'll learn

  1. Start with the simplest design that works
  2. Send big files straight to storage
  3. Do slow work in the background
  4. Say when background work is done
  5. Serve faraway viewers from nearby
  6. Keep running when a server dies
  7. Keep a copy of the database ready to take over
  8. Split a big job across many machines
  9. Grow when traffic grows ten times