Design YouTube: Adaptive Bitrate Streaming, DAG Transcoding & Edge CDN Delivery
Engineering Video at Petabyte Scale
YouTube Video Streaming & Transcoding Architecture
1. Upload Flow: Never Proxy Gigabytes Through API Servers
- Client asks API servers for a Presigned Object Storage URL (AWS S3 / GCS).
- Client uploads video chunks directly to Original Storage (
multipart/resumable upload) so dropped Wi-Fi resumes seamlessly. - Completion triggers a Transcoding Queue while metadata writes to SQL (
MySQL/Vitesswith read replicas).
2. The DAG Transcoding Pipeline
360p, 480p, 720p, 1080p, 4K).Split by GOP for Parallel Encoding
- Preprocessor splits the video at GOP (Group of Pictures) boundaries into tiny independent 2–10 second segments.
- A DAG Scheduler fans out parallel tasks across transcoding workers:
- Audio track extraction + normalization
- Video segment encoding (
360p..4K) in parallel - Watermarking, closed-caption ASR, and thumbnail generation
- Segments reassemble into streaming playlists (HLS
.m3u8or MPEG-DASH.mpd) stored in Transcoded S3 buckets.
3. Adaptive Bitrate Streaming (ABR) & CDN Economics
How ABR Prevents Buffering
.m3u8) listing segmented video URLs at each bitrate tier. Every 2–4 seconds, the player measures real-time download bandwidth—seamlessly dropping from 1080p to 480p mid-sentence if the user enters an elevator, then stepping back up without pausing.Taming Massive CDN Bandwidth Bills
- 80/20 Cache Rule: Keep the top 20% viral/popular videos pinned on CDN edge PoPs (accounting for >80% of all traffic).
- Serve Long-Tail from Origin Storage: Rarely watched 5-year-old videos with 2 views/year stream on-demand from origin object storage rather than polluting expensive edge SSDs.
- Region-Aware Transcoding: Don't waste GPU cycles encoding niche videos in 4K or exotic codecs until view counts cross a popularity threshold.
- Safety & Anti-Leeching: Serve video segments via short-lived Signed CDN URLs / Cookies and DRM tokenization.