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.9 How does CDN delivery work at this scale?
3 min read+10 XP
At 125 Tbit/s average egress, delivery is the system:
- Popularity is skewed: in the chapter's code, with a Zipf-like spread over 10 million videos, the top 1% get about 72% of views. Those segments live in every edge cache; the long tail is fetched on demand.
- Caches inside ISPs: large video services place cache servers inside internet providers' networks (Netflix's Open Connect and Google's Global Cache are examples), so most traffic never crosses the wider internet.
- Segments are immutable: cache them for a long time; only playlists of new videos change (Chapter 26).
- Origin shield and request collapsing protect storage when a video goes viral.
- Multi-CDN and smart steering for resilience and cost (Chapter 26's failure section).
Memory code: "Popular videos live at the edge; the long tail is fetched on demand."