๐ Problem Description
Design a video streaming platform like YouTube or Netflix that allows users to upload, process, and stream videos. The system should support adaptive bitrate streaming, global content delivery, recommendations, and handle billions of daily video views with minimal buffering.
๐ค Use Cases
1.
Creator wants to upload a video so that the video is processed and made available for streaming
2.
Viewer wants to search for videos so that they find relevant content
3.
Viewer wants to play a video so that they watch with minimal buffering
4.
Viewer wants to switch video quality so that stream adapts to their bandwidth
5.
Viewer wants to like, comment, subscribe so that their engagement is recorded
6.
System wants to recommend videos so that personalized content for each user
โ Functional Requirements
- โขUpload videos (up to 12 hours, various formats)
- โขTranscode videos to multiple resolutions (144p to 4K)
- โขStream videos with adaptive bitrate (ABR)
- โขSearch videos by title, description, tags
- โขRecommend personalized content
- โขSupport live streaming
- โขEngagement features: likes, comments, subscriptions
- โขMonetization: ads insertion
โก Non-Functional Requirements
- โขVideo start time (time to first byte) < 200ms
- โขMinimal buffering (< 1% rebuffer rate)
- โขSupport 5 billion video views per day
- โข500 hours of video uploaded per minute
- โขGlobal availability with low latency
- โขHigh durability - never lose uploaded content
โ ๏ธ Constraints & Assumptions
- โขVideo upload size: up to 256GB
- โขMaximum video duration: 12 hours
- โขTranscode to 6+ quality levels (144p, 240p, 360p, 480p, 720p, 1080p, 4K)
- โขThumbnail extraction at multiple timestamps
- โขGlobal CDN coverage in 100+ countries
๐ Capacity Estimation
๐ฅ Users
2B monthly active users, 1B daily views
๐พ Storage
1 exabyte total, 500PB/year new content
โก QPS
Video plays: 50K/sec, Uploads: 1K/min
๐ Bandwidth
100+ Tbps global egress
๐ Assumptions
- โข 5B video views per day
- โข 500 hours uploaded per minute = 720K hours/day
- โข Average video: 10 minutes, 500MB after encoding
- โข 80% of traffic goes to 20% of videos (hot content)
- โข Average viewer watches 40 minutes/day
- โข 6 encoding profiles per video
๐ก Key Concepts
CRITICAL
Adaptive Bitrate Streaming
HLS/DASH protocols allow clients to switch quality based on network conditions. Video is split into small segments (2-10s) at multiple quality levels.
CRITICAL
CDN Edge Caching
90%+ of video requests served from edge cache. Popular content is pre-positioned at edge nodes. Cache hit rate directly impacts latency and cost.
CRITICAL
Video Transcoding
Convert source video to multiple profiles (codec, resolution, bitrate). Parallel processing for speed. FFmpeg is the standard tool.
HIGH
Chunked Upload
Large files uploaded in resumable chunks. Allows retry on failure, parallel upload. Direct to S3 with pre-signed URLs.
HIGH
Video Segmentation
Videos split into small segments (2-10s) for streaming. Enables seeking, quality switching, and efficient caching.
MEDIUM
Hot vs Cold Content
80% of views go to 20% of videos. Hot content cached aggressively. Cold content may stream from origin.
๐ก Interview Tips
- ๐กSeparate upload/processing path from viewing path early
- ๐กExplain adaptive bitrate streaming in detail - it's core to video
- ๐กDiscuss CDN extensively - it handles 90%+ of traffic
- ๐กMention transcoding pipeline parallelism
- ๐กCover the hot vs cold content distinction
- ๐กDraw the video segment structure (HLS/DASH)