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.1 What do you ask first?
3 min read+10 XP
Step 1: Requirements (5 minutes)
| Letter | Candidate asks | Interviewer answers |
|---|---|---|
| Scope | "Upload, process, watch? Live streaming? Comments, recommendations, search? Max upload size?" | "Upload, process and watch, plus view counts. Live is a separate round (Chapter 41). Skip comments and recommendations. Uploads up to a few GB, sometimes more." |
| Count | "How much is uploaded and watched?" | "Say 500 hours of video uploaded every minute, and about a billion hours watched a day." |
| Access pattern | "How skewed is viewing?" | "Very: a small share of videos gets most of the views." |
| Latency | "How soon after upload must a video be watchable? How fast should playback start?" | "Within minutes of upload. Playback should start in a second or two and rarely stall." |
| Exactness | "Must view counts be exact and live?" | "Roughly right and a few minutes behind is fine, but not inflatable by bots." |
Agreed requirements:
- Functional (verbs): creators upload (resumable); the system processes videos into many qualities and formats; viewers watch with adaptive quality; the system counts views.
- Non-functional (adjectives): durable originals, fast processing (minutes), smooth playback (quick start, few stalls) on any network and device, global delivery at enormous bandwidth, cost-aware storage and egress, trustworthy view counts.
Interviewer pushback:
- "Why not just store the uploaded file and stream it?" → The original might be a 4K file a phone can't decode or a slow network can't carry. We need a ladder of qualities and formats, cut into segments, so every device and network can play something (Chapter 26).
Memory code: "Ask how much goes in, how much comes out, and how fast it must be watchable."