40. Design Video Upload and Streaming (YouTube)
1
The interview prompt2
40.1 What do you ask first?3
40.2 How big is this, really?4
40.3 What are the doors?5
40.4 What do we store?6
40.5 What does the whole system look like?7
40.6 How does the upload pipeline work?8
40.7 How does transcoding work?9
40.8 How does adaptive bitrate work?10
40.9 How does CDN delivery work at this scale?11
40.10 How do you count views?12
40.11 What would you say in the last five minutes?13
Score yourself14
Variations to practise15
Sources16
Code lab40. Design Video Upload and Streaming (YouTube)
40.2 How big is this, really?
3 min read+10 XP
Step 2: Estimates (5 minutes)
Assume a ladder of 240p to 1080p totalling about 10.4 Mbit/s for all qualities together, an average 3 Mbit/s watched, and encoding at an assumed half real-time per worker for the whole ladder.
| What | Working | Result |
|---|---|---|
| Hours uploaded a day | 500 × 60 × 24 | 720,000 hours |
| Rendition storage per hour of video | 10.4 Mbit/s × 3,600 s ÷ 8 | ≈ 4.7 GB |
| New renditions a day | 720,000 × 4.7 GB | ≈ 3.4 PB a day (plus originals) |
| Transcoding work | 720,000 hours ÷ 0.5 speed | 1.44 million worker-hours a day ≈ 60,000 busy workers |
| Data watched a day | 1 billion hours × 3 Mbit/s × 3,600 ÷ 8 | ≈ 1.35 EB a day |
| Average egress | 1.35 EB ÷ 86,400 s | ≈ 125 Tbit/s |
What the numbers say, out loud:
- "Egress dwarfs everything. 125 Tbit/s on average can only come from CDNs and caches inside ISPs, close to viewers, never from our data centres alone."
- "Transcoding is a huge, parallel batch workload: tens of thousands of workers, scaled by queue length, often on cheaper interruptible machines."
- "Storage grows by petabytes a day, so tier it: hot copies for popular videos, cold storage and fewer qualities for the long tail."
Interviewer pushback:
- "Do you store every quality for every video?" → Not necessarily. Most uploads get few views; encode a basic ladder first and add higher qualities or newer codecs (VP9, AV1) only for videos that get popular.
Memory code: "Petabytes in, exabytes out: the CDN is the system."