Design a video platform
Creators upload hours of video; viewers on phones, laptops and TVs press play and expect it to start in a second and never stall, on fibre or on a train. A video platform is three systems joined together: an upload path that must survive flaky connections, a processing pipeline that turns one file into dozens, and a delivery network that streams enormous amounts of data from servers close to every viewer. It follows the interview framework phase by phase.
1. The prompt
"Design YouTube: upload videos, watch them on any device, with titles, thumbnails, view counts and a home page of recommendations."
Metadata and accounts are ordinary. The interview is about three heavy paths: getting multi-gigabyte files in over bad connections, turning each into a ladder of formats quickly, and delivering more than 100 terabits a second without stalls.
2. Frame the problem
How big are uploads, and how many?
Files up to several GB; about 500 hours of video uploaded per minute.
Uploads must be resumable and go straight to storage, not through API servers.
How much is watched?
About 1 billion hours a day, on every kind of device and network.
That's ~125 Tbit/s: only a CDN, with caches inside ISPs, can deliver it.
How soon after upload must a video be watchable?
Within minutes, at least in low quality.
Transcoding must be parallel, with low resolutions first.
Live streaming?
Not in this version.
Live needs a different, latency-driven pipeline (Design D22 covers live comments).
Must view counts be exact and instant?
Approximately right within minutes; exact later for creator payouts.
Counting goes through an event stream, not database increments.
Private or paid videos?
Yes, some.
Signed, expiring segment URLs.
Moderation and copyright?
Yes, checks before or soon after publishing.
They're steps in the processing workflow.
3. What it must do
- A creator can upload a video (up to several GB) with a title, description and thumbnail.
- A viewer can watch a video on any device, at the best quality their connection allows.
- Viewers see view counts and a home feed of recommended videos.
Not now:
- Live streaming.
- Comments: a separate service.
- Monetisation.
- The recommendation model: we design around its serving layer.
4. How well it must do it
| Target | Why this number |
|---|---|
| Starts fast: playback begins within ~1 s at p90 speed | Viewers leave quickly when a video won't start. |
| Rarely stalls: rebuffering under 1% of watch time where it runs | Stalls drive viewers away more than lower quality does. |
| Reliable uploads: a 4 GB upload over a bad connection eventually succeeds without restarting where it runs | Creators upload from phones and hotel Wi-Fi. |
| Scale: 500 hours uploaded a minute; 1 billion hours watched a day load shape | Egress, not compute, is the biggest cost. |
| Durable: an uploaded video is never lost data safety | Creators' work is irreplaceable. |
5. Numbers that change the design
| Quantity | Working | → so we… |
|---|---|---|
| Upload volume | 500 h/min × 60 × 24 = 720,000 hours a day; ~1 GB per hour of source | ~720 TB a day of originals |
| Transcoded copies | ~6 resolutions, ~2–3 GB per hour in total | Another ~2 PB a day → so object storage with tiering; most videos are rarely watched |
| Streaming egress | 10⁹ hours a day ÷ 86,400 s ≈ 42M concurrent streams × ~3 Mbit/s | ~125 Tbit/s → so only a CDN (with servers inside ISPs) can deliver this |
| Transcoding compute | 720,000 hours a day, each needing several encodes | Many thousands of worker cores → so a parallel, chunked pipeline |
6. The nouns
- Video: with its status.
- Upload: a multipart upload session.
- Rendition: one resolution and bitrate.
- Segment: a few seconds of one rendition.
- Manifest: the playlists.
- View event.
videos video_id, owner_id, title, description, status (uploading | processing | ready | blocked), duration, thumbnail_key
renditions (video_id, resolution, codec) → bitrate, manifest_key, status
storage raw/{video_id} · v/{video_id}/{rendition}/{n}.m4s · v/{video_id}/master.m3u8
view events video_id, viewer, seconds_watched, time (stream → counts)
7. The contract
POST /v1/videos {title, size} → 201 {video_id, upload: {upload_id, part_urls[...]}} (presigned multipart, Module 10)
POST /v1/videos/{id}/complete {parts: [...]} → 202 (processing starts)
GET /v1/videos/{id} → {title, status, manifest_url: "https://cdn…/v/{id}/master.m3u8", thumbnail}
GET /v1/feed → recommended videos
POST /v1/videos/{id}/views {seconds_watched} (batched by the player)
Data flow: (1) the creator uploads parts straight to storage → (2) "upload complete" starts a workflow → (3) split, encode in parallel, build manifests → (4) mark ready → (5) players fetch playlists and segments from the CDN → (6) view events flow to counting.
8. First working version
An API, object storage, a queue of transcoding jobs, workers, a metadata database and a CDN.
8.1 Uploading
Version one streams the file through the API server into storage, then enqueues a transcoding job.
8.2 Transcoding
One worker takes the job and encodes the whole file into each resolution, one after another, then marks the video ready.
8.3 Watching
The player downloads one MP4 file at a fixed quality through the CDN, and each view increments a counter in the database.
Parked for later (section 9 fixes each)
- Uploads through API servers tie them up and restart from zero on a dropped connection.
- Encoding a one-hour video on one worker takes hours.
- One fixed quality stalls on slow networks and wastes data on fast ones.
- 125 Tbit/s from a regular CDN setup.
- Counting views with database writes.
- Moderation, private videos and storage cost.
9. Make it hold up
9.1 Uploading big files over bad connections reliable uploads
| Approach | Why | |
|---|---|---|
| ✗ Bad | Stream the file through the API servers in one request | Ties up servers for minutes and restarts from zero when the connection drops at 90%. |
| ~ Good | A presigned URL for one direct PUT to object storage | Servers are out of the path, but a failure still restarts the whole file. |
| ✓ Great | Multipart (resumable) upload straight to object storage: parts uploaded in parallel, each retried on its own; the client remembers the upload id and resumes from the missing parts | Fast, resilient, and the API servers only sign URLs and record metadata. The storage event "upload complete" starts processing. |
9.2 Transcoding: one file into many starts fast · scale
- Why: the uploaded file is in whatever format the camera made. Every device needs common codecs (H.264 for compatibility; more efficient codecs such as VP9, HEVC or AV1 where supported) at several resolutions and bitrates: a bitrate ladder (say 240p to 4K).
- Chunked and parallel: split the video into segments of a few seconds, encode each segment for each rendition on separate workers, then assemble. A one-hour video finishes in minutes instead of hours, and a crashed worker redoes one segment.
- As a workflow: validate → split → encode (fan-out) → assemble manifests → thumbnails → moderation and copyright checks → mark ready. A workflow engine (Module 22) tracks it, retries steps and resumes after crashes.
- Prioritise: make a low resolution available first so the video is watchable quickly, then fill in higher ones.
9.3 Adaptive streaming starts fast · rarely stalls
Each rendition is cut into segments of a few seconds and listed in a playlist (HLS .m3u8 or DASH .mpd); a master playlist lists the renditions. The player downloads segments over plain HTTPS, measures throughput and how much video it has buffered, and picks the quality for the next segment. When bandwidth drops, it steps down before the buffer empties; when it recovers, it steps back up. Because segments are ordinary files, CDNs cache them like images. Try it in section 13.
9.4 Delivering 100+ Tbit/s scale · starts fast
Popular videos are cached at CDN edges, and the biggest platforms place cache servers inside ISPs' networks (Netflix's Open Connect works this way) so traffic barely crosses the internet. Popularity is extremely skewed: a small share of videos makes most views, so edges hold the head while the long tail is fetched from regional caches or origin storage on demand. Segment URLs are signed and expiring for private or paid videos (Module 10).
9.5 Metadata, views and recommendations scale
- Metadata (titles, owners, status) is small and read-heavy: a sharded database plus a cache, with search through a search engine.
- View counts are high-volume and need not be exact in real time: players send batched events to a log; a stream job aggregates counts (Design D17) and periodically updates the displayed count, with fraud filtering for fake views.
- Recommendations are a separate system: candidate generation and ranking models trained on watch history offline, with a serving layer that returns a ranked list in milliseconds.
9.6 Storage cost and moderation durable · scale
- Tiering: keep originals and popular renditions in standard storage; move rarely watched videos to cheaper, slower tiers, and re-encode expensive codecs only for videos that become popular.
- Durability: originals are kept (replicated or erasure-coded across zones) so any rendition can be regenerated.
- Moderation and copyright: classifier and fingerprint checks run as workflow steps; videos can be held, limited or blocked, and blocks purge CDN caches.
9.7 The whole design after the deep dives
From upload to playback through the final design.
10. Interviewer follow-ups
Add live streaming.
Ingest a live feed (RTMP or SRT), transcode in real time into short segments (1–2 s), and publish playlists that update continuously; the CDN serves them like any HLS stream, with a few seconds of delay. Very low latency needs other protocols (WebRTC). It's a separate, latency-driven pipeline.
A video goes viral within an hour of upload.
Its first requests miss the edge and come from regional caches or origin; then edges fill. Pre-warm caches when early view velocity spikes, and prioritise encoding its higher resolutions and better codecs.
Cut egress cost.
More efficient codecs (AV1, HEVC) for popular videos, more ISP-embedded caches, a better bitrate ladder per video (per-title encoding), and capping quality on small screens.
Creators want analytics within minutes.
The same view-event stream feeds per-video, per-minute aggregates (Design D17) into an OLAP store for the creator dashboard.
Copyrighted content.
Fingerprint audio and video during processing and compare against reference fingerprints from rights holders. Matches can block, mute or route revenue, per the rights holder's policy.
Resume watching on another device.
Players report position periodically; a small per-user store keeps the last position per video, read when playback starts.
Multi-region failure of origin storage.
Edges keep serving cached segments. Originals and popular renditions are replicated across regions, so origin fetches fail over.
Variation: a subscription service with a fixed catalogue
A common twist: "Now design it for a paid streaming service like Netflix: no uploads, a catalogue of films and series." The pipeline above still works, but three of its assumptions flip, and the design moves with them.
- Few titles, watched a lot. Tens of thousands of titles instead of billions of videos, each watched millions of times. Encoding can be slow and thorough: a bitrate ladder tuned per title (even per scene) and several codecs, because every byte saved is saved millions of times.
- Demand you can predict. Tonight's popular titles are known this afternoon: new episodes, what's trending in each country. So the caches are filled ahead of time, during the quiet hours, instead of filling on a miss at peak time. The caches sit inside internet providers' networks, so most bytes never cross the wider internet.
- Pressing play is the hard path. One call has to check the subscription and the licence for this country, pick caches that hold the files and are close and healthy, and hand back a manifest and a decryption licence, all in a few hundred milliseconds.
- Licences by country and date. Each title has availability windows per country, so the catalogue, search and home rows are filtered per country, and a title can disappear at midnight on a fixed date.
- The home screen is personal. The rows ("because you watched…") are computed offline per user and served from a cache; only the ordering is adjusted live.
Read more: Open Connect, Netflix's own delivery network, describes appliances placed inside providers' networks and filled nightly.
11. When things break
| Failure | What users see | How we detect it | What limits the damage |
|---|---|---|---|
| Upload connection drops | A pause, then it continues | Client retries | Multipart upload resumes from missing parts |
| Encoder worker crashes | Processing takes slightly longer | Workflow step timeout | Retry that segment only |
| Transcoding backlog | New videos take longer to be ready | Queue depth and age | Autoscale workers; low resolutions first |
| CDN edge outage | Brief rebuffering | Edge health | Players switch to another edge; ABR steps down |
| View-count pipeline lag | Counts frozen briefly | Consumer lag | Counts catch up; nothing else depends on them |
12. Wrap-up and the clock
Trade-offs we made:
- Multipart uploads straight to storage.
- Chunked parallel transcoding as a workflow (more moving parts, much faster).
- Adaptive streaming over HTTP (cacheable, a few seconds of buffer).
- ISP-embedded caches for egress.
- Asynchronous view counting.
- Storage tiering and on-demand renditions (cheaper, a slower first view for old videos).
What we'd watch:
- Time to first frame.
- Rebuffering ratio.
- Upload success rate.
- Processing time to "ready".
- CDN hit rate.
- Egress cost per hour watched.
At 10×:
- More ISP caches.
- Per-title encoding.
- Aggressive tiering.
A 45-minute interview
| 0–4 | Frame the problem (upload size, watch volume, live?) |
| 4–9 | Must do, how well, numbers (125 Tbit/s) |
| 9–13 | Nouns, contract, data flow |
| 13–20 | First working version, parked list |
| 20–40 | Deep dives: uploads (9.1), transcoding (9.2), ABR (9.3), CDN (9.4) |
| 40–45 | Follow-ups and wrap-up |
A 60-minute interview
| 0–5 | Frame the problem |
| 5–11 | Must do, how well, numbers |
| 11–16 | Nouns, contract, data flow |
| 16–24 | First working version |
| 24–50 | Deep dives 9.1–9.6 and the final picture |
| 50–60 | Follow-ups: live, viral, egress cost; wrap-up |
| Level | What a strong answer shows |
|---|---|
| Mid-level | Upload to object storage, a transcoding queue and workers, a CDN, a metadata DB, basic adaptive streaming. |
| Senior | Multipart resumable uploads, chunked parallel transcoding as a workflow, HLS/DASH and how players adapt, CDN behaviour with skewed popularity, asynchronous view counting. |
| Staff+ | Storage tiering and on-demand renditions as cost levers, ISP-embedded caches, codec strategy, moderation and copyright pipelines, capacity planning for egress. |
Common mistakes:
- Uploading through API servers.
- Encoding a whole file on one machine.
- A single fixed quality.
- Ignoring egress.
- Counting views with database writes.
- Forgetting moderation.
13. Try it, check yourself, read more
A 60-second playback. The player chooses a quality for each 2-second segment from the measured bandwidth and its buffer. Pick a network and a strategy.
Ladder: 240p 0.4, 480p 1.5, 720p 3, 1080p 6 and 4K 16 Mbit/s. Top: coloured bars are the quality chosen for each segment, the dashed line is the network's real bandwidth (same scale). Bottom: the buffer; red marks stalls.
How does adaptive bitrate streaming avoid stalls?
How do you transcode a one-hour video in minutes?
Why can ordinary CDNs deliver HLS and DASH video?
A 4 GB upload drops at 90%. What design avoids starting over?
| Resource | Why |
|---|---|
| HTTP Live Streaming (Apple) | How HLS playlists, segments and variants work. |
| Netflix Open Connect | How a large streaming service places caches inside ISPs. |
| Design YouTube (Hello Interview) | Another walkthrough. |