Requirements & scope
Problem Statement & Requirements
Functional Requirements
- Upload videos -- creators upload video files (up to 10 GB), system processes and stores them
- Stream videos -- viewers watch videos with smooth playback, adaptive quality
- Search & discovery -- search by title/tags, homepage recommendations, trending
- Video metadata -- title, description, tags, thumbnails, view count, likes/dislikes
- Comments -- threaded comments on videos
- Subscriptions / channels -- users subscribe to creators, see new uploads in feed
- Watch history & resume -- track progress, resume from where user left off
- Live streaming (brief mention) -- real-time broadcast with minimal delay
Non-Functional Requirements
- Low startup latency -- video begins playing within 2 seconds
- No buffering -- adaptive bitrate prevents rebuffering on bandwidth changes
- High availability -- 99.99% uptime for playback (upload can tolerate brief outages)
- Global reach -- low latency worldwide via CDN
- Scalability -- 1B+ DAU, 500+ hours of video uploaded per minute
- Cost efficiency -- storage and bandwidth are the dominant costs
Out of Scope
- Monetization / ads system (that's a separate design)
- Creator analytics dashboard
- Copyright detection (Content ID) -- mentioned briefly
- Short-form video (TikTok-style) -- similar but different optimization profile
Scale estimations
Scale Estimations
Users & Content
| Metric | Value |
|---|---|
| Daily Active Users (DAU) | 1B |
| Total videos | 1B |
| New video uploads / day | 500 hours/min x 60 x 24 = 720,000 hours/day |
| Videos uploaded / day | ~5M (avg 8.6 min each) |
| Average video length | 8 minutes |
| Average views per user per day | 5 videos |
| Total video views / day | 5B |
Storage
| Metric | Value |
|---|---|
| Raw video avg size (1080p, 8 min) | ~1.5 GB |
| Raw uploads / day | 5M x 1.5 GB = ~7.5 PB/day |
| Transcoded versions per video | 5 resolutions x 3 codecs = ~15 versions |
| Avg transcoded size (all versions) | ~3 GB total per video |
| Transcoded storage / day | 5M x 3 GB = ~15 PB/day |
| Total storage (accumulated) | ~exabytes |
| Thumbnail storage / day | 5M x 5 thumbs x 50 KB = ~1.25 TB |
Bandwidth
| Metric | Value |
|---|---|
| Avg video bitrate (mixed quality) | 5 Mbps |
| Concurrent viewers (peak) | ~200M |
| Peak egress bandwidth | 200M x 5 Mbps = ~1 Petabit/s |
| Daily egress | ~500 PB/day |
Transcoding
| Metric | Value |
|---|---|
| Videos to transcode / day | 5M |
| Transcoding time per video (1080p, 8 min) | ~30 min per resolution |
| Total compute needed | 5M x 15 versions x 30 min = enormous |
| Transcoding cluster size | 10,000+ machines |
Layered architecture
High-Level Architecture
High-Level ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore
Detailed Architecture (Read vs Write Paths)
Detailed Architecture (Read vs Write Paths)Excalidraw diagram · editable shapes · reveal step by stepExplore
API & contracts
Workshop note · added for the website’s common reading format
For Video Streaming, define contracts around the boundary components: Creator client, Upload service, Transcode workers. Specify authentication, request identity, versioning, pagination or streaming semantics, timeouts, and retry behavior. Name which operations are idempotent and how callers discover an uncertain outcome.
The source discusses these contracts within its subsystem walkthroughs rather than as a standalone endpoint catalog. The examples in this article are design exercises, not published service APIs.
Data model
Data Model
Video Metadata (MySQL / Vitess)
Video Metadata (MySQL / Vitess)Excalidraw diagram · editable shapes · reveal step by stepExplore
View Counts at Scale
View Counts at ScaleExcalidraw diagram · editable shapes · reveal step by stepExplore
Core design decisions
Workshop note · added for the website’s common reading format
Use the detailed source walkthroughs in this article to examine Video Streaming at this layer. State the requirement, propose the smallest component that satisfies it, and make its cost and failure mode explicit.
Request flows
Video Upload Flow
Video Upload FlowExcalidraw diagram · editable shapes · reveal step by stepExplore
Multipart Upload for Large Files
Multipart Upload for Large FilesExcalidraw diagram · editable shapes · reveal step by stepExplore
Transcoding Pipeline -- The Heart of the System
Why Transcode?
Why Transcode?Excalidraw diagram · editable shapes · reveal step by stepExplore
Transcoding Output Matrix
Transcoding Output MatrixExcalidraw diagram · editable shapes · reveal step by stepExplore
Transcoding Architecture
Transcoding ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore
Parallel Transcoding Strategy
Parallel Transcoding StrategyExcalidraw diagram · editable shapes · reveal step by stepExplore
Video Playback Flow
Video Playback FlowExcalidraw diagram · editable shapes · reveal step by stepExplore
Performance & caching
Cost Optimization
Cost OptimizationExcalidraw diagram · editable shapes · reveal step by stepExplore
Advanced design
Adaptive Bitrate Streaming (ABR)
How ABR Works
How ABR WorksExcalidraw diagram · editable shapes · reveal step by stepExplore
HLS Manifest Example
HLS Manifest ExampleExcalidraw diagram · editable shapes · reveal step by stepExplore
ABR Algorithm (Client-Side)
ABR Algorithm (Client-Side)Excalidraw diagram · editable shapes · reveal step by stepExplore
CDN Architecture
Multi-Tier CDN Strategy
Multi-Tier CDN StrategyExcalidraw diagram · editable shapes · reveal step by stepExplore
CDN Content Routing
CDN Content RoutingExcalidraw diagram · editable shapes · reveal step by stepExplore
Video Player Architecture
Video Player ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore
Recommendation Engine (Brief)
Recommendation Engine (Brief)Excalidraw diagram · editable shapes · reveal step by stepExplore
Live Streaming (Brief Overview)
Live Streaming (Brief Overview)Excalidraw diagram · editable shapes · reveal step by stepExplore
Content Moderation & Copyright
Content Moderation & CopyrightExcalidraw diagram · editable shapes · reveal step by stepExplore
Edge cases
Workshop note · added for the website’s common reading format
Walk through three failure moments in Video Streaming: a request times out before its result is known; a dependency becomes slow rather than unavailable; and a process restarts after committing state but before acknowledging it.
For each case, name the authoritative record, define a safe retry, cap resource usage, and describe what the caller sees. Playback telemetry should help detect and contain the problem: Optimize user-visible startup delay, buffering, and cost rather than raw throughput alone.
Tradeoffs
Tradeoffs & Design Decisions Summary
| Decision | Option A | Option B | Chosen | Why |
|---|---|---|---|---|
| Upload | Through API server | Direct to S3 (presigned URL) | Direct S3 | Avoids bottleneck; API servers don't handle GB-sized files |
| Transcoding | Single machine per video | Parallel segment encoding | Parallel | 1-hour video: 5 min vs 2 hours |
| Streaming protocol | Progressive download | HLS / DASH (ABR) | HLS/DASH | Adaptive quality; works on all devices; industry standard |
| Segment duration | 2 seconds | 6 seconds | 6 seconds | Shorter = more requests + overhead; longer = coarser ABR switching. 6s is the industry sweet spot |
| Codec | H.264 only | H.264 + VP9 + AV1 | All three | H.264 for compatibility; VP9/AV1 for bandwidth savings on modern devices |
| CDN | Third-party (Akamai) | Own CDN (Open Connect) | Depends on scale | YouTube/Netflix: own CDN. Startups: third-party |
| View counts | Sync DB update | Async Kafka -> Redis -> DB | Async | Can't do 58K writes/sec to one row; batch aggregation |
| Storage | Single tier | Hot/warm/cold tiering | Tiered | 80% of views on 5% of videos; cold storage saves 60%+ cost |
| Transcoding scope | All resolutions immediately | Lazy (popular = more codecs) | Lazy | 90% of videos never need 4K; saves 40% compute |
| Thumbnails | Single auto-generated | Multiple + creator choice | Multiple | Auto-generate 3 candidates; let creator pick or A/B test |
| Metadata DB | NoSQL | MySQL (Vitess sharded) | MySQL/Vitess | Relational queries needed (joins for search, channels); Vitess scales MySQL horizontally |
Reliability & fault tolerance
Workshop note · added for the website’s common reading format
Optimize user-visible startup delay, buffering, and cost rather than raw throughput alone.
Set service-level objectives for the user-visible path, then map its dependencies. Define bounded retries with jitter, deadlines, and backpressure. Keep a degraded mode that protects authoritative state, and test recovery instead of treating replication as a backup.
For Video Streaming, pay special attention to Object storage, CDN when deciding failure domains and recovery procedures.
Production architecture
Production Architecture
Production ArchitectureExcalidraw diagram · editable shapes · reveal step by stepExplore
Further exploration
Workshop note · added for the website’s common reading format
Rebuild Video Streaming from memory, then change one assumption: ten times more traffic, a new region, or a stricter consistency requirement. Which component must change first—and which does not?
Compare Transcode workers with the same boundary in a related design. Write down one alternative you rejected, what it would simplify, and when you would choose it instead. Follow the source link at the end of this article to explore the original document.
Interview playbook
Interview Tips
Separate upload from playback -- These are completely different systems. "Let me design the write path (upload + transcode) first, then the read path (streaming)." This structures your answer clearly.
Transcoding is the centerpiece -- Spend the most time here. Explain why you need multiple resolutions + codecs, parallel segment encoding, and the output matrix.
ABR is what makes streaming work -- "The player dynamically switches quality based on bandwidth. This is why Netflix doesn't buffer on your phone even on a spotty connection." Draw the segment timeline with quality switches.
CDN is critical for scale -- "1 Petabit/s of egress bandwidth. No origin server handles that. You need a multi-tier CDN with edge PoPs worldwide." Mention Netflix Open Connect if you know it.
View counts are a distributed systems problem -- "5B views/day. You can't UPDATE a SQL row on every view. Buffer in Kafka, aggregate in Redis, flush to DB." This shows you think about practical bottlenecks.
Presigned URLs for upload -- "The video file goes directly from client to S3. Our API servers never touch the bytes." Simple but important.
Cost awareness differentiates senior candidates -- "Storage is the biggest cost. Tiered storage, lazy transcoding, and AV1 codec migration are how YouTube/Netflix keep costs manageable at exabyte scale."
HLS manifest is worth showing -- Write out the master playlist. It's concrete, shows you know the actual protocol, and takes 30 seconds to draw.
Don't forget startup latency -- "Start with lowest quality for the first 2 segments, then ramp up. This gives sub-2-second time-to-first-frame."
Mention live streaming briefly -- "Live is similar but uses RTMP for ingest and LL-HLS for playback with 2-6 second segments. The key difference is real-time transcoding instead of batch."