Video Streaming (YouTube)
Overview
Designing a Video Streaming platform (YouTube, Netflix) is a complex system design question that tests CDN usage, adaptive bitrate streaming, and handling massive media files. The core challenges include: storing and serving petabytes of video, transcoding into multiple resolutions/bitrates, and delivering smooth playback globally with low latency. This design matters in interviews because it combines object storage, transcoding pipelines, CDNs, and client-side logic—and requires thinking about cost (egress, storage) and quality of experience. Demonstrating you understand HLS/DASH, chunked uploads, and how to scale transcoding shows you can design systems for media at scale.
Requirements
Functional
- Upload videos (support large files, resumable)
- Transcode into multiple resolutions (240p–4K)
- Adaptive bitrate streaming (HLS/DASH)
- Video playback with low startup time
- Thumbnails, metadata, search
- Live streaming (optional)
Non-Functional
- Low latency — video start <2 seconds
- High availability — 99.99%
- Global distribution — CDN edge caching
- Cost efficiency — minimize egress and storage
Capacity Estimation
Assume 500 hours uploaded/day, 1B views/day. 500 * 5GB = 2.5TB upload/day. 1B * 500MB avg stream = 500PB egress/day (mitigated by CDN).
Architecture Diagram
Component Deep Dive
Upload Service
Chunked upload (multipart). Assembles chunks, stores in object store. Initiates transcoding job.
Transcoding Pipeline
FFmpeg or cloud transcoder. Produces multiple resolutions, HLS/DASH manifests. Parallel workers.
Object Store
S3/GCS. Stores raw uploads, transcoded segments, thumbnails. Versioned for durability.
CDN
CloudFront, Cloudflare. Caches video segments at edge. Reduces origin load and latency.
Metadata Service
Video metadata, user data, playlists. PostgreSQL/Cassandra. Powers search and recommendations.
Streaming Service
Serves HLS/DASH manifests and segments. Redirects to CDN URL. Handles range requests.
Database Design
Videos: video_id, user_id, title, status, created_at. Segments: video_id, resolution, segment_url. Users, playlists in PostgreSQL. Segment URLs point to CDN.
API Design
| Method | Path | Description |
|---|---|---|
POST | /api/upload/init | Initiate upload. Returns upload_id, chunk_urls. |
PUT | /api/upload/{id}/chunk | Upload chunk. Multipart. |
POST | /api/upload/{id}/complete | Finalize upload. Triggers transcoding. |
GET | /api/videos/{id}/stream | Get HLS/DASH manifest. Returns .m3u8 or .mpd URL. |
GET | /api/videos/{id} | Get video metadata. |
Scalability & Trade-offs
- Transcoding: Pre-transcode all resolutions increases storage; on-demand reduces storage but adds latency.
- CDN: Push to CDN on upload vs pull-through. Push ensures availability; pull-through saves cost for unpopular videos.
- Chunk size: Smaller chunks = faster start, more requests; larger = fewer requests, slower start.
Related System Designs
URL Shortener (TinyURL)
The URL Shortener (TinyURL-style) system design is a classic interview question that tests your understanding of distrib...
InfrastructureRate Limiter
A Rate Limiter system design question tests your understanding of distributed systems, consistency, and real-time decisi...
StorageKey-Value Store
Designing a distributed Key-Value Store (like Redis or DynamoDB) is a staple system design question at companies buildin...