System Design Problems
Design YouTube
YouTube serves 2B+ monthly active users with 500+ hours of video uploaded every minute. This design covers video upload pipelines, adaptive streaming, CDN delivery, and recommendation systems.
- Scale â 2B MAU, 500+ hours uploaded/minute, 1B hours watched/day
- Storage â Exabytes of video content
- Streaming â Adaptive bitrate with sub-second startup
YouTube's core challenge is the asymmetric nature: massive storage for uploads, massive bandwidth for streaming.
Requirements Clarification
Functional Requirements
- Upload videos with metadata
- Stream videos with adaptive quality
- Search videos by title/tags
- Like, comment, subscribe
- View personalized recommendations
- Live streaming
- Short-form content (Shorts)
Non-Functional Requirements
- Availability: 99.99% uptime
- Latency: Video starts in < 2 seconds
- Durability: Videos must never be lost
- Consistency: Eventual consistency for counts
- Scale: 1B hours of video watched daily
Back-of-the-Envelope Estimation
High-Level Architecture
Video Upload Pipeline
Transcoding Pipeline
Adaptive Streaming
HLS vs DASH
| Feature | HLS | DASH |
|---|---|---|
| Protocol | Apple's HTTP Live Streaming | Dynamic Adaptive Streaming |
| Segment Format | MPEG-TS | fMP4/CMAF |
| Manifest | m3u8 | MPD |
| DRM | FairPlay | Widevine/PlayReady |
| Latency | 6-30 seconds | 2-10 seconds |
CDN Architecture
Recommendation System
Data Model
Practice Exercises
-
Upload Design: Design a resumable upload system that handles 10GB files. How do you handle network failures mid-upload?
-
Transcoding: How would you prioritize transcoding? Should a viral video be transcoded before an old personal video?
-
Live Streaming: Design a live streaming system with < 5 second latency. How does this differ from VOD?
-
Storage Optimization: Propose a storage tiering strategy for videos with decreasing popularity over time.
What to Learn Next
-> Design Netflix Content delivery and adaptive streaming.
-> Design Instagram Media delivery and feed generation.
-> Design Amazon E-commerce at scale.
-> Design Google Search Web-scale indexing and ranking.
-> Back Pressure Managing load in streaming systems.
-> Caching Strategies CDN and edge caching patterns.