System Design · Hard
Design a youtube video sharing
Ingest, transcode, store, and stream video at massive scale with adaptive bitrate.
Requirements
What the system must do, and how well it must do it.
Functional
Upload videos up to 12 hours, 256 GB, multiple codecs.
Transcode to adaptive bitrate ladder (144p to 4K/8K).
Stream via DASH/HLS with adaptive quality switching.
Support live streaming and premieres.
Non-functional
99.9% upload success rate; resumable for large files.
Transcoding starts within 1 minute of upload complete.
Stream start latency under 2 seconds (CDN hit).
Support 1B hours watched/day, 500 hours uploaded/minute.
Estimation
Back of the envelope numbers that drive the design.
500 hrs/min upload = 30K hrs/day. Average 1 GB/hr = 30 PB/day raw.
ABR ladder: 8 renditions × 30 PB = 240 PB/day new transcoded data.
CDN: 1B hrs/day × 2 Mbps avg = 250 Tbps sustained egress.
Metadata: 30K videos/day × 10 KB = 300 MB/day.
Architecture
Design decisions
Chunked upload
Large videos are split into chunks (for example 64 MB each). The client uploads chunks in parallel to pre-signed URLs. The upload service verifies checksums and assembles the original in object storage. This enables pause/resume and survives network interruptions.
Encoding pipeline
A distributed transcoder (FFmpeg on Kubernetes or cloud transcoder) pulls jobs from the queue. It generates an ABR ladder: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p. Each rendition is segmented (6-second chunks) and packaged as DASH (MPD) and HLS (m3u8). Thumbnails, sprites, and captions are generated in parallel. Outputs go to video storage (object storage with CDN).
Adaptive streaming
The player requests the manifest (MPD/m3u8), then selects the highest quality the bandwidth allows. It switches seamlessly by requesting chunks from different renditions. The CDN caches chunks at the edge. Pre-warming popular videos reduces origin load.
Live streaming
The broadcaster pushes RTMP/SRT to an ingest point. A live transcoder segments in real time (2-6 second chunks) and writes to a low-latency HLS/DASH manifest. The CDN caches live chunks with short TTL. DVR window (rewind) is implemented by keeping the last N hours of segments.
Questions and answers
Follow-ups an interviewer is likely to ask. Try answering before you open each one.
How do you handle copyright detection?
Run Content ID fingerprinting in the encoding pipeline (async, after upload). Matches are flagged; the uploader can dispute. Monetisation claims redirect ad revenue. This is a separate pipeline from transcoding to avoid blocking publish.
What about 8K and AV1?
Add renditions to the ladder as codecs mature. AV1 encoding is CPU-intensive; use hardware-accelerated encoders (GPU/ASIC) or cloud transcoders. Serve AV1 only to clients that advertise support.
How do you reduce storage cost?
Tier storage: hot (recent, popular) on SSD, warm on HDD, cold (archival) on Glacier. Delete unreferenced renditions. Use per-title encoding to avoid wasting bits on simple content.