We use cookies for site analytics. Accept to help us understand how the site is used. See our Privacy Policy for details.
Encoding ladders, adaptive bitrate, CDN economics, and the difference between live and VOD. Petabyte-scale storage meets millisecond-scale playback.
Design a service that lets users upload video, stores it durably, transcodes it into multiple qualities, and streams it to viewers globally with sub-second startup and adaptive quality. Variants: VOD (video on demand, like YouTube/Netflix), live streaming (Twitch/YouTube Live), or both.
Video is one of the highest-bandwidth, highest-cost design questions. The interesting decisions are: how to transcode efficiently, how the encoding ladder is structured, how the CDN absorbs petabit-scale traffic, and the operational cost of every choice.
Asking these before diving into a solution is the difference between a "hire" and a "no signal" rating. Pick the questions whose answers would change your design.
Storage
Egress bandwidth
Transcoding compute
Live ingestion
Manifest serving
Two distinct pipelines share the storage layer.
Upload + transcode (offline)
Source upload → object storage → transcode workflow → encoding ladder outputs → CDN origin → CDN edge → viewer.
Live (streaming)
Broadcaster → ingest endpoint (regional) → live transcoder → segment storage (short retention) → CDN edge → viewer. Latency: ingest-to-viewer is the SLA.
Shared layers
Object storage (source + outputs), CDN, manifest service, analytics pipeline, recommendation/discovery service.
Resumable uploads (TUS or S3 multipart). Validates, deduplicates, stores raw source in object storage. Triggers transcode workflow.
Step Functions / Airflow / proprietary. Splits source into chunks, fans out to GPU transcode workers, assembles outputs at each ladder rung, generates HLS/DASH manifest.
GPU-accelerated. Encodes a chunk into one ladder rung output. Stateless workers; orchestrator handles state.
Source video and all encoding ladder outputs. Multi-region replication for hot content; single-region cold tier for long-tail.
Generates and serves HLS/DASH manifests. Cached at CDN edge. Includes ad insertion markers if applicable.
Edge servers globally. Caches segments. Origin pulls from object storage on miss. Petabit-scale capacity.
RTMP / WebRTC / SRT endpoints regionally distributed. Broadcasters connect; gateway forwards to live transcoder.
Real-time transcode of incoming live streams. Outputs HLS segments (typically 2-6s each) to segment storage.
Tracks per-user watch progress, history. Source for recommendations.
Watch events, completion rates, quality metrics. Drives recommendations, ads, business analytics.
The subsystems where the interview is actually decided. Skim if you're running short; own these if you want a strong signal.
An encoding ladder is the set of (resolution, bitrate, codec) tuples generated for each source video. The ladder is the central economic decision in video.
Standard ladder (illustrative)
| Rung | Resolution | Bitrate | Codec | Audience |
|---|---|---|---|---|
| 1 | 240p | 400 kbps | H.264 | Slow mobile |
| 2 | 360p | 800 kbps | H.264 | Mobile |
| 3 | 480p | 1.4 Mbps | H.264 | Mobile/wifi |
| 4 | 720p | 3 Mbps | H.264 | HD desktop/wifi |
| 5 | 1080p | 6 Mbps | H.264 | Full HD |
| 6 | 1440p | 12 Mbps | H.265 | High-end |
| 7 | 4K | 25 Mbps | H.265/AV1 | 4K screens |
Codec choices
Per-title encoding (Netflix's innovation)
Different content compresses at different rates. A still-frame interview compresses far smaller than an action sequence at the same quality. Per-title encoding analyzes each video's complexity and produces a custom ladder, saving 20-30% of bandwidth.
Encoding chunks
Source video is split into 2-10 second chunks. Each chunk is independently encoded by a different worker. Embarrassingly parallel - 1 hour of video transcodes in 1 minute on 60 parallel workers.
Storage bloat
A 1-hour 4K source = 13 GB. With a 7-rung ladder, total encoded outputs = ~25 GB (the lower rungs are tiny). Aggressive lifecycle: low-watch tail content can drop to 3 rungs (mobile-friendly only) after a year, saving storage.
Adaptive bitrate (ABR) means the player switches between encoding ladder rungs as network conditions change. The two protocols are HLS (Apple) and DASH (everyone else).
Manifest structure
The manifest lists all available rungs and the URLs of their segment files. Player downloads the manifest, picks a starting rung based on initial bandwidth measurement, requests segments, monitors download time, switches rungs up or down.
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=400000,RESOLUTION=240p
240p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3000000,RESOLUTION=720p
720p.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=6000000,RESOLUTION=1080p
1080p.m3u8
Segment design
Segments are typically 2-10 seconds long. Shorter = faster quality switching, more manifest churn. Longer = smoother playback, slower adaptation.
Switching algorithm
Player measures recent download throughput. If bandwidth > current rung × 1.5, step up. If bandwidth < current rung, step down (to avoid stalling).
Initial rung selection
The first segment is the slowest to download because we don't know bandwidth yet. Start low (480p) for fast first-frame, ramp up after 1-2 segments. Trade-off: low first-frame quality vs slow startup.
Pre-fetching and CDN warming
Player fetches the next 1-2 segments speculatively. The CDN must serve them with low TTFB - a slow CDN miss kills perceived quality. Aggressive edge caching is essential.
Video delivery is a CDN problem. The transcoding pipeline produces outputs once; the CDN delivers them billions of times. CDN cost is the dominant operational expense.
Cache hit rate matters everything
At 99% hit rate, origin egress = 1% of total. Origin storage costs are bounded by content volume. CDN costs scale with viewers.
At 95% hit rate, origin egress = 5%. 5x the storage egress cost. Cache hit rate is a critical KPI.
Cache hierarchy
Hot content is short
80% of views go to <1% of content. The hot working set fits in edge cache. Long-tail content takes a small bandwidth share but lives mostly in origin.
Cache key design
Each segment is keyed by (video_id, ladder_rung, segment_id). Identical content → same key globally. Personalized content (ads inserted) breaks caching - design ad insertion to be client-side or done at origin once per ad.
CDN strategy: build vs buy
Multi-CDN
Many services use 2-3 CDN providers and route based on cost / performance / capacity. Multi-CDN offers redundancy (one CDN going down doesn't kill playback) and pricing leverage.
The interview signal
CDN cost is the dominant operational concern in video. Candidates who design without acknowledging CDN economics miss the central trade-off.
Live streaming shares the storage and CDN layers but the playback path is different.
Ingest
Broadcasters connect to a regional ingest endpoint via RTMP, SRT, or WebRTC. Ingest gateway authenticates, forwards to live transcoder.
Real-time transcoding
Live transcoder must keep up with input. 1 hour of live = 1 hour of transcode (real-time, not batch). GPU-accelerated; same encoding ladder concept as VOD but with tighter latency.
Segment generation
Live transcoder writes new segments every 2-6 seconds. Each segment is uploaded to a segment store (object storage with very short retention) and added to the live manifest.
Manifest update
Live manifests are periodically refreshed - players poll for the latest segment list. Usual cadence: every 2-3 seconds.
Latency sources (60 seconds total in standard live)
Low-latency live (LL-HLS, DASH-LL, WebRTC)
Live stream lifecycle
Concurrent broadcasters at scale (Twitch)
At 100K+ concurrent broadcasters, the live transcoder pool dominates compute cost. Many broadcasters have very few viewers - cheap-encode for them; reserve high-quality encode for popular streams. Dynamic allocation based on viewer count.
Exabyte-scale storage at petabyte cost requires tiering.
Hot tier (last 30 days)
SSD-backed object storage. Read-optimized. ~$0.025/GB/month. Holds: recently uploaded videos, currently popular content.
Warm tier (30 days - 1 year)
HDD-backed object storage. ~$0.008/GB/month. Holds: most videos. Reads still serve in milliseconds.
Cold tier (>1 year)
Glacier / nearline. ~$0.001/GB/month. Reads take minutes. Holds: long-tail content with very low watch rate.
Re-tiering
Background process: track watch rate per video over rolling 30-day window. Move videos with watch rate < threshold to colder tiers. Move videos with sudden watch spike to hotter tiers (e.g., a 5-year-old clip goes viral).
Source vs ladder retention
Source video is the most expensive (4K = 13 GB/hour). Outputs are cheaper. Some services delete the source after 1 year and re-transcode from the highest-rung output if needed (loses some quality but saves PB).
Replication strategy
Lifecycle automation
S3 / equivalent lifecycle policies. Encode the rules (after N days move to warmer/colder). Don't write your own lifecycle service - cloud providers do this well.
The economics
At YouTube-scale (1+ exabyte hot, 100s of EB warm/cold), storage tiering saves $100M+/year vs all-hot. This is one of the highest-leverage operational decisions in the system.
The video pipeline is necessary but not sufficient. Discovery is what keeps users engaged.
Search index
Title, description, tags, transcript indexed in ElasticSearch / equivalent. Updated on upload. Includes engagement signals (views, like ratio) for ranking.
Recommendations pipeline
Two-tower neural network common today. Inputs: user history, video metadata, contextual features. Outputs: top-K candidate videos. Re-ranked by online model with freshness, diversity, calibration.
Watch graph
User → video edges with weights (watch duration, engagement). Used both for collaborative filtering and for content discovery. Stored in graph DB or as sparse matrix in object storage.
Trending detection
Real-time: video gets X views in Y minutes → flag as trending. Needs streaming pipeline (Flink, Spark Streaming) consuming watch events.
Personalization vs editorial
Pure personalization creates filter bubbles. Most platforms blend personalized recommendations with editorial picks (trending, recommended-for-you mixed with what's hot globally).
Cold-start (new content)
A just-uploaded video has no watch signals. Bootstrap with: creator's prior history, content metadata (transcript, visual features from CV models), thumbnail click-through rate. After 1-10K views, use real engagement.
Cold-start (new users)
Newly registered. Show globally trending + a wide content sample. Lock in preferences quickly via implicit signals.
The interview signal
Designing the playback pipeline correctly without the discovery layer means designing a successful upload tool, not a successful product. Always note discovery as a critical adjacent system.
Encoding ladder breadth vs storage cost
More ladder rungs = better quality match per device = better experience. More rungs = more storage. Most services run 5-7 rungs and reduce to 3-4 for long-tail content.
Codec choice: licensing vs efficiency
H.264 is universal but bandwidth-expensive. H.265 saves 50% bandwidth but costs licensing. AV1 saves another 30% but costs encoding compute. Mix codecs strategically by content tier and viewer device.
Live latency vs stability
Low-latency live (sub-second) requires shorter segments, smaller buffers, more rebuffer risk. Standard live (30s) is more stable but feels less "live." Match the latency tier to the use case (sports → low-latency, recorded events → standard).
CDN: build vs buy
Buy is the right answer at small scale. Build is the right answer at exabyte scale. The crossover happens around $50M/year of CDN spend.
Storage tier aggressiveness
Aggressive cold-tiering saves money but adds latency for long-tail content (rare views take minutes to restore). Conservative tiering keeps everything fast but expensive. Tune based on actual watch distribution.
Per-title encoding investment
Per-title encoding saves 20-30% bandwidth but costs analysis compute on every upload. Worth it for high-watch content; overkill for low-watch.
Be ready for at least three of these. The first one is almost always asked.
Reading is the floor. The interview signal is in walking through this live with someone probing follow-ups. Use the AI mock interview to practice talking through requirements, architecture, and trade-offs out loud.
Start an AI mock interview →