Vibe Engines
YouTube
System Design

Design YouTube

Step 1 / 9

Learn system design by building a video platform like YouTube step by step.

The numbers to beat5–6quality rungs~4sper segmentasyncvia queue

The whole design, in writing

Learn system design by building a video platform like YouTube step by step. An interactive guide covering metadata vs blob storage, the async transcoding pipeline and ABR ladder, CDN edge delivery, tiered hot/cold storage, scaling the control plane, async watch analytics, and resumable uploads, Content-ID and live.

Every step of the build above, written out: the problem each piece solves, the option that was taken and the ones that were not, the numbers, and how it fails in production.

The big idea

How does YouTube stream to a billion screens?

A creator uploads one enormous file. Billions of viewers — on fibre, on 3G, on a TV — must each watch it starting in under a second, in the best quality their connection can handle, without buffering.

Upload UIPlayer
New in this step: Upload UI, Player. · swipe to pan the diagram

The trick is that you never serve "the video." You serve a metadata lookup, then a flood of tiny pre-encoded segments from a server near the viewer. Almost everything here is about turning one raw upload into something a CDN can spray across the planet.

What the new pieces do

Upload UIcreator
A creator uploading a huge raw file. Uploads once and wants it watchable everywhere, in every quality.
Playerviewer
Anyone hitting play. Expects the video to start in under a second and never buffer, on any connection.

Step 1 · The skeleton

Split the bytes from the facts

A video is two very different things: a few hundred bytes of metadata (title, owner, status) and gigabytes of raw media. Storing them the same way is a mistake.

App ServerUpload ServiceMetadata DBBlob Store
New in this step: App Server, Upload Service, Metadata DB, Blob Store. · swipe to pan the diagram

A video is a few hundred bytes of metadata plus gigabytes of raw media. How do you store them?

  1. Gigabyte media blobs bloat a database, make queries slow, and waste its expensive indexed storage. Databases are for small structured queryable data, not opaque write-once files.

  2. Object storage is great for the giant media but terrible for the queryable facts (title, owner, status, search) you constantly look up. You need a database for those.

  3. Tiny structured facts go in a queryable database; huge write-once media goes in cheap object storage. Watch requests read metadata first, then fetch bytes — splitting them is the foundation.

Keep facts in a Metadata DB and bytes in a Blob Store (object storage like S3). The Upload Service streams the raw file into the blob store and writes a small row in the metadata DB. Watch requests read metadata first, then go get bytes.

What the new pieces do

App Serveredge
The front door for uploads and watch requests. Becomes an API Gateway behind a load balancer.
Upload Serviceservice
Accepts the raw upload (resumable, in chunks), stashes it in blob storage, and queues it for processing.
Metadata DBstore
Small structured data: title, description, owner, status, and the manifest of available renditions.
Blob Storestore
Object storage (S3-like) holding the giant raw upload and every encoded segment. The origin behind the CDN.

Step 2 · The pipeline

One file becomes many

The raw upload is useless for streaming: it’s one giant file in one codec at one resolution. A phone on 3G and a 4K TV need wildly different versions.

Transcoderencode ABREncode Jobsqueue
New in this step: Transcoder, Encode Jobs.

The raw upload is one giant file in one codec. A 3G phone and a 4K TV need different versions. How do you produce them?

  1. Re-encoding per view is enormously expensive and slow — you’d redo the same work for every viewer. Encode once, up front, into all qualities and reuse.

  2. The upload service drops a job on a queue; a transcoder fleet re-encodes into 240p–4K, each chopped into small ~2–10s segments written back to blob, then marks the video ready. The player switches quality mid-stream from the precomputed ladder (HLS/DASH).

  3. Creators upload one master file and can’t be expected to produce a full ABR ladder of segmented renditions. Encoding is the platform’s job, done asynchronously off the upload path.

Make encoding asynchronous. The Upload Service drops a job on a queue; a fleet of Transcoder workers re-encode the file into an ABR ladder — 240p, 480p, 720p, 1080p, 4K — each chopped into small (~2–10s) segments, then written back to the blob store. When done, they mark the video ready in metadata.

  • 5–6quality rungs
  • ~4sper segment
  • asyncvia queue

What the new pieces do

Transcoderworker
Workers that re-encode the raw file into many resolutions and bitrates, split into small streamable segments.
Encode Jobsbus
A job queue decoupling fast uploads from slow encoding. Transcoder workers pull jobs at their own pace.

Back of the envelope

1 upload → 5–6 rungs × segments
~6× storage per video
~2–10s per segment
switchable mid-stream (HLS/DASH)
encode async via queue
slow encoding off the fast upload path

Step 3 · The hot path

Serving the watch

Views dwarf uploads by orders of magnitude, and viewers are everywhere on Earth. Streaming every segment from one origin datacenter would be slow and ruinously expensive.

PlayerApp ServerTranscoderCDN EdgeBlob Store
New in this step: CDN Edge. · swipe to pan the diagram

Views dwarf uploads and viewers are everywhere. Streaming every segment from one origin would be slow and ruinous. Fix?

  1. More origin capacity in one place still pays a long round-trip to distant viewers and concentrates bandwidth cost. You need bytes physically close to users.

  2. Pre-downloading gigabytes wastes bandwidth (most of a video is never watched) and delays start. You want to stream small segments on demand from a nearby edge.

  3. The player pulls the manifest then segments from the nearest edge; the first regional viewer warms the cache, everyone after gets bytes from down the street. Immutable segments cache perfectly — the CDN offloads 95%+ of traffic. The CDN IS the read-scaling strategy.

Put a CDN in front of the blob store. To watch, the player fetches the manifest (from metadata) then pulls segments from the nearest CDN edge. The first viewer in a region warms the cache; everyone after gets bytes from down the street. Origin traffic stays tiny.

  • 95%+served at edge
  • <1sstart time
  • immutablesegments

What the new pieces do

CDN Edgeedge
Thousands of edge servers near users. Serves the actual video bytes so the origin barely gets touched.

Back of the envelope

95%+ served at the edge
origin barely touched
immutable segments
cache forever, no invalidation
1st regional view warms cache
the rest served locally, <1s start

Step 4 · A mountain of bytes

Storing exabytes affordably

Every upload now becomes 5–6 renditions, each in many segments — multiplying storage. Hundreds of hours are uploaded every minute. You cannot keep it all hot.

Upload UIPlayerApp ServerUpload ServiceTranscoderCDN EdgeMetadata DBBlob StoreEncode Jobs
The system as it stands at this step. · swipe to pan the diagram

Every upload becomes 5–6 renditions in many segments, and 500 hours arrive every minute. How do you store exabytes affordably?

  1. A tiny fraction of videos drive most views — keep those replicated and ready; let the millions of near-zero-view uploads sit in cheap cold tiers, accepting a slower first byte if someone finally watches them.

  2. Replicating everything everywhere is ruinously expensive when most videos are barely watched. Match storage cost to popularity — hot content hot, cold content cheap.

  3. Deleting creators’ uploads to save space is unacceptable — they expect permanence. The answer is cheaper cold storage for the long tail, not deletion.

Lean on tiered blob storage: replicate popular content across regions for fast origin pulls, and push the long tail of rarely-watched videos to cheaper cold storage. Generate thumbnails and previews once, store them as blobs too, and serve them from the CDN.

  • 500 hrsuploaded / min
  • storage per video
  • tieredhot + cold

Back of the envelope

500 hrs uploaded / minute
× ~6 renditions = exabytes
hot: replicated + ready
the tiny fraction driving most views
cold: cheap, slower first byte
the long tail nobody watches

Step 5 · Don’t fall over

Scale the control plane

The CDN handles the bytes, but metadata reads, search, and upload coordination still hit your services — and one big server is a single point of failure.

Upload UIPlayerAPI GatewayUpload ServiceTranscoderCDN EdgeMetadata DBBlob StoreEncode Jobs
The system as it stands at this step. · swipe to pan the diagram

The CDN handles bytes, but metadata reads, search and upload coordination still hit your services, and one server is a SPOF. How do you scale them?

  1. A bigger box has a ceiling and is still a single point of failure, and it can’t isolate an upload spike from the read-heavy watch path. You need many instances and separation of concerns.

  2. Coupling uploads/encoding (write) with watch-metadata/search (read) means a surge in one takes down the other. Their traffic shapes are totally different — isolate them.

  3. Run many stateless instances behind a load balancer with a hot-metadata cache, and separate upload, watch-metadata and search so each scales — and fails — independently, keeping the 99% read path resilient when writes surge.

Put a load balancer in front and run many stateless copies of each service. Add a read cache for hot metadata. Split upload, watch-metadata, and search into services that scale — and fail — independently, so a spike in uploads never takes down playback.

Step 6 · Count the views

Views, watch time & recs

Owners and the recommender want view counts, watch time, and quality stats. Writing a row on every play — and incrementing a counter on a viral video — would hammer the database.

CDN Edgeglobal PoPsView Analyticswatch events
New in this step: View Analytics.

Owners want view counts and watch time, but a DB write per play (and a counter bump on a viral video) would hammer it. How?

  1. Plays emit events into an analytics pipeline; counts aggregate in the background (approximated for hot videos), and recommendations train on the same stream — never on the playback critical path. If analytics lags, playback is unaffected.

  2. A synchronous counter bump per play on a viral video is a write hotspot that can melt the DB and adds latency to playback. Counting must be async and off the hot path.

  3. Client-only counts are unverifiable and easily gamed, and still need to reach the server. Emit events to a pipeline that aggregates and validates server-side.

Make it asynchronous. The player emits lightweight watch events that flow into an analytics pipeline; counts are aggregated in the background and approximated for hot videos. Recommendations train on this same event stream — never on the playback critical path.

What the new pieces do

View Analyticsstore
Aggregates views, watch time and quality switches asynchronously, so counting a view never slows playback.

Step 7 · The sharp edges

Uploads, copyright & live

Real life intrudes: uploads fail halfway on flaky connections, pirated content appears, and some events must stream live with seconds of delay, not after a full encode.

Upload UIPlayerAPI GatewayUpload ServiceTranscoderCDN EdgeMetadata DBBlob StoreEncode JobsView Analytics
The system as it stands at this step. · swipe to pan the diagram

Use resumable, chunked uploads so a dropped connection retries only the missing chunk. Run a content-matching system (fingerprinting) to flag copyrighted material. For live, encode segments on the fly and publish the manifest continuously — same ABR + CDN idea, just streaming as it happens.

You did it

You just designed YouTube.

Upload UIPlayerAPI GatewayUpload ServiceTranscoderCDN EdgeMetadata DBBlob StoreEncode JobsView Analytics
The finished design, end to end. · swipe to pan the diagram

Everything you assembled, in order

  • Split tiny metadata (DB) from huge media (blob store).
  • Async transcoding turns one raw file into an ABR ladder of segments.
  • Adaptive bitrate lets the player switch quality without buffering.
  • A CDN serves immutable segments from the edge — 95%+ offload.
  • Tiered hot/cold blob storage keeps exabytes affordable.
  • Async watch events drive view counts and recommendations.
  • Resumable uploads, content-ID, and live streaming for the real world.

Where an interviewer pokes next

Getting the boxes right is the easy half. These are the questions that separate a candidate who drew the diagram from one who has run the thing. Answer each one out loud before you open it.

  1. How does adaptive bitrate (ABR) decide which quality to play?

    The client decides, per segment. The player measures its recent download throughput and buffer level and picks the highest rung the connection can sustain, stepping down when bandwidth drops and back up when it recovers — which is why video gets fuzzy then sharp instead of freezing. The server just offers the ladder via the HLS/DASH manifest; keeping the decision on the client keeps the serving tier stateless and simple.

  2. How are resumable uploads implemented?

    Chunked upload against an upload session: the client splits the file into chunks uploaded against a session id; the server tracks which chunks it has, so a dropped connection retries only the missing chunks (verified with checksums). Protocols like tus or S3 multipart formalize it. It turns a flaky multi-gigabyte upload from "start over" into "resume where you left off."

  3. How does Content-ID / copyright matching work at scale?

    Each upload is fingerprinted (a robust perceptual hash of audio/video) and matched against a database of reference fingerprints from rights holders. Matches trigger policy — block, monetize, or track — without a human watching every video. It runs asynchronously after upload (off the hot path), the same way transcoding does, because it’s expensive and not needed before processing.

  4. How does live streaming differ from video-on-demand here?

    Same ABR + CDN idea, but encode-as-you-go: segments are produced continuously from the live feed and the manifest updates in real time, so viewers stay a few segments (seconds) behind live. You trade some latency for the same adaptive, cacheable segment delivery. The differences are a continuously-growing manifest, tighter encode latency, and no ability to re-encode the past.

  5. Why is splitting metadata from blobs the foundation of the whole design?

    Because the two have opposite needs and scales. Metadata is tiny, structured, queryable, frequently updated — perfect for an indexed, searchable database. Media is gigabytes, opaque, write-once, read-via-CDN — perfect for cheap object storage. Mixing them makes the database huge and slow and wastes money; splitting lets each use the right tool and scale independently, which transcode, CDN and tiering all build on.

Check yourself — the answers, and why

Eight steps in, these are the calls you should be able to make cold. Pick one, then read why.

  1. Tiny metadata and gigantic media are stored…

    • Both in the database
    • Separately — metadata in a DB, media in a blob store
    • Both on the CDN

    Structured queryable facts in a DB; huge write-once files in cheap object storage.

  2. Transcoding one upload into an ABR ladder is done…

    • On the fly per viewer
    • Asynchronously via a job queue, up front
    • By the uploader

    Encode once into many qualities/segments off the upload path; the player switches among them.

  3. A CDN is ideal here because video segments are…

    • Large
    • Immutable and re-watched — perfect cache targets
    • Private

    Edge-cached immutable segments offload 95%+ of traffic and start playback in <1s.

  4. Exabytes stay affordable via…

    • Deleting old videos
    • Tiered hot/cold storage matched to popularity
    • One global replica

    Replicate the hot fraction; push the rarely-watched long tail to cheap cold storage.

  5. View counts are computed…

    • Synchronously on every play
    • Asynchronously from a watch-event stream
    • In the player only

    Plays emit events; aggregation (and recs) happen off the playback critical path.

How you’d open this design in an interview

Before any boxes: agree what it must do, pin the qualities that shape everything, then build — naming each trade-off as you make it. The walkthrough above is that exact order.

What it must do

Agree on these before drawing a single box.

  • Upload: accept one enormous raw file from a creator (resumable, in chunks).
  • Transcode: turn that file into every quality and small streamable segments.
  • Watch: start playback in under a second and adapt quality to the viewer’s connection.
  • Count views: view counts, watch time and quality stats — plus recommendations.
  • Keep it forever: store every video durably and affordably at exabyte scale.

The qualities that shape everything

Each one names the mechanism that buys it.

The DB isn’t bloated by media
Split tiny structured metadata (title, owner, status) into a queryable DB and the gigabyte bytes into a cheap blob store.
One file plays on 3G and a 4K TV without buffering
Async transcoding builds an ABR ladder of small segments; the player switches resolution mid-stream from a HLS/DASH manifest.
Start in <1s and spare the origin
A CDN serves immutable segments from an edge near the viewer — the first regional view warms the cache and it offloads 95%+ of traffic.
Exabytes stay affordable
Tiered blob storage: replicate the popular fraction across regions, push the rarely-watched long tail to cheaper cold storage.
An upload spike never takes down playback
A load balancer fronts stateless service copies, and read (watch/metadata) is split from write (upload/encode) so each scales and fails on its own.
Counting a view never slows playback
The player emits lightweight watch events onto a stream, aggregated in the background — recommendations train on the same stream, off the hot path.

The trade-offs you say out loud

Senior signal isn’t the boxes — it’s naming what you gave up and why it was the right price.

Metadata in a DB, bytes in a blob store over storing the media in the database

Gigabyte media blobs bloat a database, slow its queries, and waste its expensive indexed storage — while object storage can’t serve the queryable facts you constantly look up. The two have opposite needs; splitting them lets each use the right tool and scale independently.

Encode once, async, into an ABR ladder over transcoding on the fly per view

Re-encoding per viewer redoes the same expensive work every time. Drop an encode job on a queue, build 240p–4K segments once off the upload path, and let the player switch among the precomputed ladder as bandwidth changes.

A CDN of immutable segments over more origin servers in one region

Origin capacity in one place still pays a long round-trip to distant viewers and concentrates bandwidth cost. Immutable, re-watched segments cache perfectly at the edge, cut latency, and offload 95%+ of traffic — the CDN is the read-scaling strategy.

Tiered hot/cold storage over replicating every rendition everywhere

A tiny fraction of videos drive most views, so replicating everything everywhere is ruinous — and deleting creators’ uploads is unacceptable. Keep the hot fraction replicated and ready; let the long tail sit in cheap cold storage with a slower first byte.

What this teaches

Learn system design by building a video platform like YouTube step by step. An interactive guide covering metadata vs blob storage, the async transcoding pipeline and ABR ladder, CDN edge delivery, tiered hot/cold storage, scaling the control plane, async watch analytics, and resumable uploads, Content-ID and live.

Key takeaways

  • Split tiny metadata (DB) from huge media (blob store).
  • Async transcoding turns one raw file into an ABR ladder of segments.
  • Adaptive bitrate lets the player switch quality without buffering.
  • A CDN serves immutable segments from the edge — 95%+ offload.
  • Tiered hot/cold blob storage keeps exabytes affordable.
  • Async watch events drive view counts and recommendations.
  • Resumable uploads, content-ID, and live streaming for the real world.

Concepts covered

  • How does YouTube stream to a billion screens?
  • Split the bytes from the facts
  • One file becomes many
  • Serving the watch
  • Storing exabytes affordably
  • Scale the control plane
  • Views, watch time & recs
  • Uploads, copyright & live
built to be streamed, not memorized — make the calls, kill the CDN, run the gauntlet.
Finished this one? 0 / 65 System Designs done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More System Designs