Design a video streaming platform
breadth · 45 min · senior/staff
Setting
You're building the upload-to-playback pipeline for a video platform: creators upload raw video, it needs to become smoothly playable on phones, laptops, and TVs over widely varying network conditions, worldwide.
The ask
Design the system that ingests an uploaded video, prepares it for playback, and serves it to viewers with minimal buffering regardless of their connection.
Constraints & scale
- ~500K uploads/day, average 10 minutes; ~1B playback-hours/month across the globe
- Playback must adapt to the viewer's bandwidth in real time (no manual quality selection required) and start within ~1–2 s of pressing play
- Processing an upload into playable form should complete in well under real time (a 10-minute upload ready in a few minutes, not a few minutes per minute of footage)
- Popular new uploads can spike to millions of views within hours; unpopular long-tail content still needs to be servable on demand years later
- Content must be served from edge locations near the viewer, not from one origin per request
What a strong answer covers
Requirements → estimates (storage, encoding fan-out, egress) → high-level diagram (ingest/transcode pipeline, storage, CDN delivery, adaptive playback) → 1–2 deep dives → trade-offs. Likely probes: the transcoding pipeline's parallelism, adaptive bitrate mechanics, and cold-start vs. hot-content caching at the edge.
A 45-minute plan
- 0-5 min · Requirements
- 5-10 min · Estimates/API
- 10-25 min · High-level
- 25-40 min · Deep dive
- 40-45 min · Wrap
What to cover, in order
- Requirements
- Estimates (storage, encoding fan-out, egress)
- High-level diagram (ingest/transcode pipeline, storage, CDN delivery, adaptive playback)
- 1–2 deep dives
- Trade-offs
Where the follow-up questions go
Pick one of these for your deep dive before the interviewer picks for you.
- The transcoding pipeline's parallelism
- Adaptive bitrate mechanics
- Cold-start vs. hot-content caching at the edge
Key trade-offs
Decisions a strong answer weighs, and what pushes each one either way.
- Bitrate ladder. More renditions give a better fit for every connection and cost transcoding time and storage for every video. A fixed ladder is simple, while a per-title ladder saves bandwidth for easy content and needs analysis. Spend the extra effort where a video will be watched a lot.
- Segment length. Short segments let players switch quality quickly and start sooner, and increase request count and per-segment overhead. Long segments are more efficient and slower to adapt. A few seconds is typical, and you should say why.
- Transcode everything now or lazily. Producing every rendition at upload makes playback ready at once and wastes work on videos nobody watches. Producing popular renditions first and others on demand saves compute and makes the first viewer of an old video wait. The long tail makes this decision important.
- Codec choice. Newer codecs cut bandwidth substantially and take much more compute to encode and are not supported on every device. Offering several codecs multiplies storage.
- CDN strategy. Filling the cache on the first request is automatic and means the first viewers of a new video hit the origin. Pushing popular or predicted content to edges ahead of time costs bandwidth and spares the origin. A tiered cache between edge and origin absorbs misses.
Common mistakes
What goes wrong most often on this problem, and why it hurts.
- Transcoding a whole upload on one machine. The work takes longer than the video, which breaks the processing-time requirement.
- Serving one large file. Without segments, a player cannot switch quality or seek cheaply, and a viewer on a weak connection stalls.
- Letting the server pick quality. The client sees its own throughput and buffer, so the choice belongs there, using the manifest the server provides.
- Treating the CDN as magic. A new, popular video starts with empty caches, and without a plan the origin takes the first wave of traffic.
- No retry or validation in the pipeline. Uploads fail halfway and transcodes crash. Make steps idempotent and resumable, and verify the output before publishing.
Graded on
Requirements & scoping · Estimation · API & data model · High-level architecture · Deep dive · Scalability & performance · Reliability & consistency · Trade-offs · Operability · Communication & drive