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)
Score yourself
3 min read+10 XP
Score yourself
Give yourself 0, 1 or 2 points per row.
| Area | 0 points | 1 point | 2 points |
|---|---|---|---|
| Requirements | Started drawing | Upload and watch | Processing time, smooth playback, devices, skew and view counts agreed |
| Estimates | None | Numbers, not used later | Egress, transcoding and storage numbers drove CDN, autoscaling and tiers |
| API and data | Skipped | Upload endpoint only | Resumable upload, status, playlist URL, view events; originals vs renditions |
| High-level design | Stream the original | Upload + storage | Pipeline, CDN watch path and counting walked |
| Deep dive | Hand-waved | One topic | Parallel transcoding, ABR, CDN at scale or view counting done properly |
| Trade-offs | None named | Named when asked | Raised unprompted (ladder size vs cost, segment length, exact vs live counts) |
| Communication | Long silences | Mostly clear | Thought out loud, checked in, managed time |
12 to 14: strong hire signal. 8 to 11: solid, polish the weak rows. Under 8: redo the round in a week, timer on.
The bar: fresher vs SDE-2
| Fresher | SDE-2 | |
|---|---|---|
| Upload | Upload to S3 | Resumable, direct, validated, with visible status |
| Processing | "Convert to MP4" | Segment-parallel DAG, ladder, progressive publishing, retries |
| Playback | Download the file | HLS/DASH with ABR, buffer-aware, segment length trade-offs |
| Delivery | "Use a CDN" | Egress maths, ISP caches, shields, immutable segments, multi-CDN |
| Counts | Increment a column | Watch threshold, de-duplication, sharded counters, async fraud checks |
Common mistakes
- Serving the original file instead of a ladder of segments.
- Transcoding a whole video on one machine.
- Uploading through app servers, or without resume.
- Forgetting egress cost and scale; treating the CDN as an afterthought.
UPDATE videos SET views = views + 1on every play of a viral video.
Quick check
Five questions on this chapter. Pick an answer, then check it.
quiz