InterviewKata
System design · Worked design D11 of 46 · Social and content · Long form

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

  1. A creator can upload a video (up to several GB) with a title, description and thumbnail.
  2. A viewer can watch a video on any device, at the best quality their connection allows.
  3. Viewers see view counts and a home feed of recommended videos.

Not now:

4. How well it must do it

TargetWhy this number
Starts fast: playback begins within ~1 s at p90 speedViewers leave quickly when a video won't start.
Rarely stalls: rebuffering under 1% of watch time where it runsStalls drive viewers away more than lower quality does.
Reliable uploads: a 4 GB upload over a bad connection eventually succeeds without restarting where it runsCreators upload from phones and hotel Wi-Fi.
Scale: 500 hours uploaded a minute; 1 billion hours watched a day load shapeEgress, not compute, is the biggest cost.
Durable: an uploaded video is never lost data safetyCreators' work is irreplaceable.

5. Numbers that change the design

QuantityWorking→ so we…
Upload volume500 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 totalAnother ~2 PB a day → so object storage with tiering; most videos are rarely watched
Streaming egress10⁹ 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 compute720,000 hours a day, each needing several encodesMany thousands of worker cores → so a parallel, chunked pipeline

6. The nouns

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)

  1. Uploads through API servers tie them up and restart from zero on a dropped connection.
  2. Encoding a one-hour video on one worker takes hours.
  3. One fixed quality stalls on slow networks and wastes data on fast ones.
  4. 125 Tbit/s from a regular CDN setup.
  5. Counting views with database writes.
  6. Moderation, private videos and storage cost.

9. Make it hold up

9.1 Uploading big files over bad connections reliable uploads

ApproachWhy
✗ BadStream the file through the API servers in one requestTies up servers for minutes and restarts from zero when the connection drops at 90%.
~ GoodA presigned URL for one direct PUT to object storageServers are out of the path, but a failure still restarts the whole file.
✓ GreatMultipart (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 partsFast, 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

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

9.6 Storage cost and moderation durable · scale

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.

Read more: Open Connect, Netflix's own delivery network, describes appliances placed inside providers' networks and filled nightly.

11. When things break

FailureWhat users seeHow we detect itWhat limits the damage
Upload connection dropsA pause, then it continuesClient retriesMultipart upload resumes from missing parts
Encoder worker crashesProcessing takes slightly longerWorkflow step timeoutRetry that segment only
Transcoding backlogNew videos take longer to be readyQueue depth and ageAutoscale workers; low resolutions first
CDN edge outageBrief rebufferingEdge healthPlayers switch to another edge; ABR steps down
View-count pipeline lagCounts frozen brieflyConsumer lagCounts catch up; nothing else depends on them

12. Wrap-up and the clock

Trade-offs we made:

What we'd watch:

At 10×:

A 45-minute interview

0–4Frame the problem (upload size, watch volume, live?)
4–9Must do, how well, numbers (125 Tbit/s)
9–13Nouns, contract, data flow
13–20First working version, parked list
20–40Deep dives: uploads (9.1), transcoding (9.2), ABR (9.3), CDN (9.4)
40–45Follow-ups and wrap-up

A 60-minute interview

0–5Frame the problem
5–11Must do, how well, numbers
11–16Nouns, contract, data flow
16–24First working version
24–50Deep dives 9.1–9.6 and the final picture
50–60Follow-ups: live, viral, egress cost; wrap-up
LevelWhat a strong answer shows
Mid-levelUpload to object storage, a transcoding queue and workers, a CDN, a metadata DB, basic adaptive streaming.
SeniorMultipart 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:

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?

Quality is decided segment by segment, stepping down before the buffer runs out.

How do you transcode a one-hour video in minutes?

Segments are independent; many workers encode them at once, and a failure redoes only one segment.

Why can ordinary CDNs deliver HLS and DASH video?

Segments and playlists are cacheable files fetched over HTTPS like any other.

A 4 GB upload drops at 90%. What design avoids starting over?

Each part is retried on its own; the upload id lets the client resume.
ResourceWhy
HTTP Live Streaming (Apple)How HLS playlists, segments and variants work.
Netflix Open ConnectHow a large streaming service places caches inside ISPs.
Design YouTube (Hello Interview)Another walkthrough.