Design a Video Streaming Platform (YouTube, Hotstar)
Design upload, transcoding, adaptive bitrate streaming and CDN delivery, including live events with crores of concurrent viewers.
Advanced · about 5 hours · difficulty 4/5
Learn first: Object Storage and Large Files, Content Delivery Networks (CDNs), Message Queues and Async Processing
Disney+ Hotstar has served live cricket to more than 5 crore concurrent viewers. Video systems are mostly about moving huge bytes efficiently, and the CDN does most of the work.
Requirements
- Upload videos (creator side), process them, and stream to any device on any network.
- Smooth playback on 3G to fibre; start fast; low rebuffering.
- For live: low delay and massive, spiky concurrency at match moments.
- Metadata, search, recommendations, view counts.
Upload and processing (VOD)
- Client uploads to object storage using resumable multipart uploads via pre-signed URLs.
- An upload event triggers a transcoding pipeline (a DAG of jobs on a queue): split into chunks, transcode each chunk in parallel into multiple resolutions and bitrates (240p to 4K) and codecs (H.264, H.265, AV1), generate thumbnails, run checks.
- Output is packaged into small segments (2 to 6 seconds) with manifests for HLS and DASH.
Playback
The player downloads the manifest, then fetches segments, switching quality per segment based on measured bandwidth: adaptive bitrate streaming (ABR). Segments are static files, perfect for CDNs; popular content is pre-positioned at edges (Netflix even places servers inside ISPs).
Live streaming
Ingest from the stadium encoder (RTMP or SRT), transcode in real time into ABR ladders, package into short segments, push to CDNs. Trade-off: shorter segments mean lower latency but more requests and overhead. At peak, the hard problems are CDN capacity, origin shielding, pre-scaling ahead of predicted spikes (toss, last overs) and degrading gracefully (cap the max bitrate for everyone instead of failing).
Other pieces
Metadata in a relational or document DB, view counts aggregated via a stream (approximate is fine), watch history in a wide-column store, DRM for premium content.
Pitfalls
- Serving video from your app servers instead of CDN and object storage.
- Transcoding an entire 2-hour file on one machine.
- Autoscaling reactively for live events; you must pre-scale.
You are ready to move on when you can trace a video from upload to a viewer's screen on a weak 4G connection, and explain how live cricket survives a 3x spike in a minute.
Key concepts
- Resumable uploads
- Transcoding pipeline as a DAG
- Segments and manifests (HLS, DASH)
- Adaptive bitrate streaming
- CDN delivery and pre-positioning
- Live ingest and low latency
- Pre-scaling for live events
- DRM
Mini project
Use ffmpeg to transcode a video into a 3-rung HLS ladder (360p, 720p, 1080p), serve it from object storage or a static server behind a CDN, and play it with hls.js while throttling bandwidth in DevTools to watch quality switch. Write up the pipeline design.
Check yourself
Why does adaptive bitrate streaming split video into short segments, and what is the trade-off of making live segments even shorter?
Free resources
- HTTP Live Streaming (Apple)
- Netflix Tech Blog (Netflix)
- Disney+ Hotstar tech blog (Hotstar)
- FFmpeg documentation (FFmpeg)