Skip to main content

YouTube: Requirements & High-Level Design

Editorial

Problem Statement

Design a video platform like YouTube. Creators upload videos of up to 256 GB or 12 hours from any connection, and an upload that breaks off resumes where it stopped. Every upload is processed into versions that play on every device — several resolutions and codecs, cut into short segments — with thumbnails and copyright checks, and it becomes watchable within minutes. Viewers watch on phones, computers and TVs: playback starts within two seconds and the quality follows the network without stalling. Videos are public, unlisted or private. The watch page shows view counts. The service has billions of monthly users; hundreds of hours of video arrive every minute and a billion hours are watched every day.

The functional requirements below come from its verbs; the rest of the statement sets the non-functional ones.

Introduction

YouTube was founded in 2005 and bought by Google in 2006. The numbers it has published since describe a system built mostly for watching:

WhatNumberPublished
Video uploaded"more than 500 hours of fresh video per minute"YouTube, at press events in May 2019
Video watched"a billion hours of YouTube's incredible content every single day"YouTube's blog, February 2017
Videos stored"nearly 10 billion public videos"; median 35 views eacha random sample of YouTube, 2022
Shorts"averaging over 200 billion daily views"YouTube's press page, 2026
Revenueads $40.4 billion (2025); ads and subscriptions over $50 billion a year (2024)Alphabet's annual report; its CEO

Every hour uploaded is watched, on average, well over a thousand hours. That ratio shapes the whole design: an upload is worth almost any amount of work if it makes each of those viewing hours cheaper, faster or better.

What makes the system hard:

ChallengeWhy it is hard
Huge, fragile uploadsFiles of tens of gigabytes arrive over phone connections that drop. A break at 80% must not cost the first 80%
Processing costsEvery upload becomes many versions — resolutions times codecs. The efficient codecs take several times the computing of the old one
Speed to watchA creator wants the video live in minutes; a 4K version takes far longer to make than a 360p one
DeliveryA billion hours a day is tens of millions of simultaneous streams. Sent from a few data centers, every byte would cross the internet for every view
The long tailMost videos are watched a few dozen times; a tiny fraction draws almost all the views. Caches must hold the head without paying for the tail
Networks changeA phone moves from Wi-Fi into a tunnel. The player must change quality before its buffer runs dry
CountingA popular video's views arrive from many viewers at once, and the counts must leave out bots

The Design in One Paragraph

An upload goes straight to object storage in a resumable session: fixed-size chunks, each acknowledged, so a broken connection resumes from the last chunk. When it completes, a processing graph starts: probe the file, check it, and encode a ladder of renditions — resolutions times codecs — each cut into segments of a few seconds that start at the same frames in every rendition. A low-resolution path is scheduled first, so the video becomes playable within minutes, and higher qualities are added as they finish. Viewers fetch a manifest and then segments over HTTP from caches — inside ISPs, at edge sites, at regional sites — which hold the popular head of the catalogue; misses fall back to object storage. The player chooses each segment's quality from its buffer and recent throughput. Metadata lives in a database sharded by video; views are sent as events and counted by a separate job.

Related lessons: the building blocks are in HTTP/1.1 to HTTP/2 to HTTP/3 (QUIC), Global Load Balancing: GeoDNS & Anycast, Idempotency: Safe to Retry, Message Queues: Absorbing the Burst, Delivery Semantics: At-Most, At-Least, Exactly-Once, Cache Eviction: LRU, LFU, TTL, FIFO, Stampedes, Thundering Herds & Cache Warming, CDNs: Caching at the Edge and CDN Invalidation & Edge Strategies (Fundamentals of System Design), Block vs File vs Object Storage, Design an S3: Blob Storage as a System, Erasure Coding vs Replication, Media Chunking, Video Transcoding Pipelines, Choosing a Shard Key, Resharding & Hot Shards and Outbox + CDC: Reliable Events from Your Database (Data Systems at Scale), Distributed Locks & Leases and Retries, Budgets & Retry Storms (Distributed Systems & Reliability), Streaming Engines and Windowing & Exactly-Once (Architecting Production Systems), and Pattern: Handling Large Blobs and S3 & Object Storage, Inside-Out (System Design Interview Mastery).

Functional Requirements

We extract the operations from the verbs of the problem statement:

FR1 — Upload videos. A creator uploads a file of up to 256 GB or 12 hours, whichever is less — YouTube's own limit. An upload that breaks off continues from where it stopped, and the stored file is checked against what the client sent.

FR2 — Process them. Each upload is turned into renditions at several resolutions and codecs, cut into segments for adaptive streaming, with thumbnails, and checked against copyright references and the platform's rules. A low-quality version becomes watchable first; higher qualities follow.

FR3 — Watch. A viewer plays a video on any device, seeks anywhere in it, and gets the quality the network can carry. Unlisted videos play for anyone with the link; private ones only for the people allowed.

FR4 — Manage. The creator sets the title, description and visibility, and sees the processing state.

FR5 — Count. The watch page shows the number of views and likes, counted after invalid views are removed.

Out of scope: search and recommendations, comments, live streaming, ads, the Shorts feed, subscriptions and notifications. Each is a system of its own.

Non-Functional Requirements

The rest of the problem statement gives the quality requirements:

  • "starts within two seconds" → Latency
  • "follows the network without stalling" → Smooth playback
  • "watchable within minutes" → Freshness
  • "resumes where it stopped" → Reliability of uploads
  • "billions of monthly users", "a billion hours" → Scale

Three more follow from what the service is: Availability, Durability and Security.

Latency

  • Playback starts within 2 seconds for most plays. A study of 23 million views found that viewers "start to abandon a video if it takes more than 2 s to start up, with each incremental delay of 1 s resulting in a 5.8% increase in the abandonment rate."

Smooth playback

  • Few stalls: the player keeps a buffer and lowers the quality before the buffer runs out.

Freshness

  • A low-quality version is watchable within minutes of the upload finishing. Higher qualities may take longer: YouTube says "A 4K video with a frame rate of 30fps that is 60 minutes long can take up to 4 hours to finish high-resolution processing."

Reliability

  • A broken upload loses at most the chunk in flight. An acknowledged upload is never lost.

Availability

  • Watching: 99.99% — about 52 minutes a year. Each minute of a full outage would cost on the order of $95,000 of YouTube's 2024 ads and subscription revenue.

Durability

  • Uploads and renditions are kept in object storage designed for 99.999999999% durability a year, as Amazon S3 and Google Cloud Storage both state.

Security

  • Upload URLs expire and reach only their own object. Private videos' segments are served only with a valid playback token.

Scale

  • Estimated next, from YouTube's own figures.

Resource Estimation

What YouTube Publishes

YouTube publishes few totals, and the ones it has published are years old. We use them with their dates:

FactValueSource
Video uploaded"more than 500 hours of fresh video per minute"YouTube at press events, May 2019
Video watched"a billion hours of YouTube's incredible content every single day"YouTube's blog, February 2017
Public videosabout 10 billion; mean length 615 s, median 126 s; median 35 viewsa random sample of YouTube, 2022
Shorts"averaging over 200 billion daily views"YouTube's press page, 2026
Upload limit256 GB or 12 hours, whichever is lessYouTube Help
Recommended upload bit rates8 Mb/s for 1080p at 30 frames a second; 35–45 Mb/s for 2160pYouTube Help

Our Design Point

AssumptionValueWhy
Uploaded500 hours a minuteYouTube's newest published figure
Watched1 billion hours a daythe same, from 2017
An upload's bit rate8 Mb/s on averageYouTube's recommendation for 1080p at 30 frames a second; for 4K it advises 35–45 Mb/s
A stream's bit rate2 Mb/s on averagebetween the 720p (0.9 Mb/s) and 1080p (1.7 Mb/s) rungs of the VP9 ladder we measured, with some 4K on televisions
Busiest hour2× the day's averageour assumption
Segment length4 sthe player fetches one segment of video at a time

Traffic

WhatCalculationResult
Videos uploaded720,000 hours a day ÷ 615 s a video~4.2 million a day, about 49 a second
Upload bandwidth720,000 hours × 3,600 s × 8 Mb/s ÷ 86,400 s240 Gb/s on average
Streams playing at once1 billion hours ÷ 24 hours41.7 million on average
Delivery bandwidth41.7 million × 2 Mb/s83 Tb/s on average, 167 Tb/s in the busiest hour
Segment requests41.7 million ÷ 4 s10.4 million a second for video alone
Watching per hour uploaded1 billion ÷ 720,0001,389 hours
Watching outweighs uploading 1,389 to 1: YouTube's own figures, turned into rates. Uploaded: 720,000 hours a day (500 hours a minute, 2019); about 49 uploads a second at the mean length of 615 seconds; 240 Gb/s arriving at 8 Mb/s each; 2.6 PB of originals a day to keep. Watched: a billion hours a day (YouTube, 2017); 41.7 million streams at once on average; 83 Tb/s leaving at 2 Mb/s each; 10.4 million segment requests a second with 4-second segments. Hours watched per hour uploaded: 1,389; bits leaving per bit arriving: 347. Every upload is worth almost any work that makes its viewing cheaper: more encodes, more codecs, caches near the viewers.

Bandwidth is set by the streams playing at the same moment, not by how many plays start each second: multiplying starts per second by a bit rate undercounts by the length of a viewing, here by a factor of thousands. And the two directions are not alike: 347 bits leave for every bit that arrives. The upload side is a large but ordinary data-transfer problem; the delivery side is why YouTube places caches inside other companies' networks.

Storage

WhatCalculationResult
Originals, kept for re-encoding720,000 hours × 3,600 s × 8 Mb/s2.6 PB a day, about 0.95 EB a year
Renditions of a 1080p uploadVP9 up to 1080p (3.64 Mb/s, measured) + H.264 up to 1080p (12.07 Mb/s, Apple's ladder)5.1 PB a day
An AV1 ladder3.69 Mb/s up to 1080p, measuredencoded only for videos whose views pay for it
The public catalogue10 billion videos × 615 s1.7 billion hours

The H.264 ladder dominates the renditions because its bit rates are fixed: on our test film Apple's 1080p rung spent 5.9 Mb/s where VP9, which adapts to the picture, spent 1.7. Spending bits by content rather than by a table is the per-title encoding of the deep dives. Object storage adds its own redundancy on top of these numbers; it is the store's job, priced into the store.

What an Outage Costs

YouTube's ads earned $40.4 billion in 2025 — about $77,000 a minute — and ads and subscriptions together passed $50 billion a year in 2024, about $95,000 a minute. That is the order of what a minute of total outage forgoes, and why the design avoids any single component that every view depends on.

Data Model

The metadata is small next to the video: a few rows per video against gigabytes of segments. It lives in a relational database split by video_id; the bytes live in object storage and are referenced by key.

-- A channel owns videos; one person can run several channels.
CREATE TABLE channels (
  channel_id   bigint      PRIMARY KEY,
  handle       text        NOT NULL UNIQUE,            -- the @name in channel URLs
  title        text        NOT NULL,
  created_at   timestamptz NOT NULL DEFAULT now()
);
-- One row per video: what the watch page and the player need.
CREATE TABLE videos (
  video_id     char(11)    PRIMARY KEY,                -- random id, the v= of the watch URL
  channel_id   bigint      NOT NULL REFERENCES channels,
  title        text        NOT NULL,
  description  text        NOT NULL DEFAULT '',
  visibility   text        NOT NULL DEFAULT 'private' CHECK (visibility IN ('public', 'unlisted', 'private')),
  state        text        NOT NULL DEFAULT 'uploading'
                           CHECK (state IN ('uploading', 'processing', 'playable', 'failed', 'blocked')),
  duration_ms  integer,                                -- known once the upload has been probed
  original_key text,                                   -- the upload as received, kept for re-encoding later
  created_at   timestamptz NOT NULL DEFAULT now(),
  published_at timestamptz
);
-- A channel's list of videos, sharded by channel: the videos themselves are spread by video_id.
CREATE TABLE channel_videos (
  channel_id   bigint      NOT NULL REFERENCES channels,
  created_at   timestamptz NOT NULL,
  video_id     char(11)    NOT NULL REFERENCES videos,
  PRIMARY KEY (channel_id, created_at, video_id)
);
-- An upload in progress: the client resumes against it; the server checks what arrived.
CREATE TABLE upload_sessions (
  session_id   uuid        PRIMARY KEY,
  video_id     char(11)    NOT NULL REFERENCES videos,
  object_key   text        NOT NULL UNIQUE,            -- a fresh key per session, so a leaked URL reaches nothing else
  size_bytes   bigint      NOT NULL,
  sha256       bytea,                                  -- declared by the client, checked against the stored object
  expires_at   timestamptz NOT NULL,
  completed_at timestamptz
);
-- The processing graph: one row per task of a video, and the tasks it waits for.
CREATE TABLE tasks (
  video_id     char(11)    NOT NULL REFERENCES videos,
  task         text        NOT NULL,                   -- 'probe', 'encode vp9 1080', 'package vp9 1080', 'check', ...
  needs        text[]      NOT NULL DEFAULT '{}',      -- tasks that must be done before this one may start
  priority     smallint    NOT NULL DEFAULT 5,         -- lower first: the low-resolution path is 0, so it publishes first
  state        text        NOT NULL DEFAULT 'waiting' CHECK (state IN ('waiting', 'running', 'done', 'failed')),
  attempts     smallint    NOT NULL DEFAULT 0,
  lease_until  timestamptz,                            -- a worker's claim; a claim that runs out is taken again
  PRIMARY KEY (video_id, task)
);
-- Every rendition the player may be offered; a row appears once its segments and manifest are stored.
CREATE TABLE renditions (
  video_id     char(11)    NOT NULL REFERENCES videos,
  codec        text        NOT NULL CHECK (codec IN ('h264', 'vp9', 'av1')),
  height       smallint    NOT NULL,
  kbps         integer     NOT NULL,
  segment_ms   integer     NOT NULL,
  ready_at     timestamptz NOT NULL DEFAULT now(),
  PRIMARY KEY (video_id, codec, height)
);
-- The counts the watch page shows, written by the counting job, never by each view.
CREATE TABLE video_counts (
  video_id     char(11)    PRIMARY KEY REFERENCES videos,
  views        bigint      NOT NULL DEFAULT 0,
  likes        bigint      NOT NULL DEFAULT 0,
  counted_to   timestamptz NOT NULL                    -- every validated event up to here is included
);
  • channels — the creator's account on the site. One person can run several channels; videos belong to a channel.
  • videos — one row per video, everything the watch page needs. The id is random — 11 characters of URL-safe text, like YouTube's — so it reveals neither the order of uploads nor how many there are, and it spreads evenly across shards. state moves uploading → processing → playable (or failed, blocked). original_key keeps the upload itself: re-encoding the catalogue with a newer codec needs the original, not a rendition.
  • channel_videos — a channel's list of videos, newest first. It repeats three columns of videos so that a channel page is one query on one shard: the videos are spread by video_id, this list by channel_id.
  • upload_sessions — one row per upload in progress: where the bytes go, how big the file is, its SHA-256, when the session expires. The client resumes against it; the server checks the finished object against it.
  • tasks — the processing graph of each video: one row per step, with the steps it needs and a priority. Workers take ready tasks with a lease (next section).
  • renditions — what the player may be offered. A row appears only when a rendition's segments and manifest are stored, so the manifest never names segments that do not exist.
  • video_counts — the counts on the watch page, written by the counting job up to counted_to, never by each view.

Elsewhere

DataWhereKeySize
The upload as receivedobject storageoriginal_keygigabytes per video
Segments of every renditionobject storage, cached near viewersvideo, codec, height, segment numbermost of the bytes served
Manifests (DASH, HLS)object storage, cachedvideokilobytes
Thumbnailsobject storage, cachedvideokilobytes
View eventsa partitioned logvideo ida few hundred bytes per view
Playback tokens for private videossigned by the API, checked at the cache—none stored

API Design

Three kinds of traffic reach the servers: small API calls to the metadata servers, upload bytes to the upload service, and segment requests to the caches. Every API call carries the user's OAuth token.

Start an Upload

POST /v1/uploads

Request:

{
  "title": "How a video gets to your phone",
  "visibility": "private",
  "size_bytes": 6442450944,
  "sha256": "6d3f0a1c…",
  "content_type": "video/mp4"
}

Response (201 Created): {"video_id": "dQw4w9WgXcQ", "session_uri": "https://upload.example.com/v1/sessions/7f2c9d…", "chunk_bytes": 8388608, "expires_at": "2026-10-22T09:00:00Z"} — the session URI is unguessable, reaches only this video's object, and expires: it is the credential for the bytes, so it is sent only over TLS and never logged.

Upload a Chunk

PUT {session_uri}

Request: the next chunk_bytes of the file, with Content-Range: bytes 0-8388607/6442450944. Chunk sizes are multiples of 256 KiB, as in Google's protocol.

Response (308 Resume Incomplete): Range: bytes=0-8388607 — the bytes the server has. The last chunk instead gets 201 Created with {"video_id": "dQw4w9WgXcQ", "state": "processing"}, once the stored object's SHA-256 matches the declared one; a mismatch gets 422 and nothing is published.

Resume After a Break

PUT {session_uri}

Request: an empty body with Content-Range: bytes */6442450944.

Response (308 Resume Incomplete): Range: bytes=0-5368709119 — continue from the next byte. This is the protocol of YouTube's own Data API.

Get a Video

GET /v1/videos/{video_id}

Response (200 OK):

{
  "video_id": "dQw4w9WgXcQ",
  "title": "How a video gets to your phone",
  "state": "playable",
  "duration_ms": 734000,
  "manifest_url": "https://media.example.com/v/dQw4w9WgXcQ/manifest.mpd",
  "thumbnail_url": "https://media.example.com/v/dQw4w9WgXcQ/default.jpg",
  "views": 1245890
}

For a private video, manifest_url carries a short-lived signed token that the caches check on every segment request. While processing continues, the manifest lists the renditions that exist so far.

Fetch Segments

GET https://media.example.com/v/{video_id}/{codec}-{height}/{segment}.m4s

Response (200 OK): the segment's bytes, from the nearest cache that holds them. Segments never change once written, so they are cached for as long as there is room.

Report a View

POST /v1/views

Request: {"view_id": "8f1c2e…", "video_id": "dQw4w9WgXcQ", "position_ms": 0} — sent when playback starts; view_id is chosen by the player, so a retry is recognised.

Response (202 Accepted): empty. The event goes to the view log; the count on the watch page changes when the counting job has validated it.

High-Level Design

We build the design up one requirement at a time.

1. One Server

The simplest video site takes the upload in one request, encodes it, keeps it on its disk and streams it to whoever asks.

Step 1: one server does everything. It receives, encodes, stores and serves every video. A creator's laptop sends a 10 GB file in one PUT to one server, which encodes it and writes every file to its disk; phones and a TV stream from the same server. Four things break: an upload broken at 80% starts from byte 0; one hour of video in VP9 takes about 9 CPU-hours for each rung of the ladder; a billion hours watched a day is 41.7 million streams at once; and when the one disk fails, every video is gone.

Every requirement breaks:

  • An upload that breaks off starts again. A 10 GB upload lost at 80% sends the first 8 GB a second time.
  • Encoding needs more computing than one machine has. VP9 took 9.3 CPU-seconds per second of a busy scene in our measurement: about 9 CPU-hours for one hour of video, for one rung of the ladder, and the ladder has a dozen.
  • Viewers need more bandwidth than one site can serve. A billion hours a day is 41.7 million streams at once, about 83 Tb/s.
  • One disk holds every video. When it fails, they are gone.

2. Uploads Straight to Storage, Resumably

The API never carries a video's bytes. It opens an upload session and hands the client a URI for it; the client sends the file in chunks directly to object storage.

Step 2: the bytes go straight to storage, resumably. The API opens a session; the file travels in chunks; the hash is checked. (1) The creator's client sends the file's size and SHA-256 to the upload service, which writes a session row in the metadata database and (2) answers with the session URI. (3) The client sends the file to object storage in chunks of 8 MiB; each is answered with 308 and the bytes held so far, and every upload gets a fresh object key. (4) Storage reports the completed object to the upload service, which (5) checks that the hash matches and only then hands the video to processing. A break costs one chunk; the URI expires and reaches one object; nothing is processed before the hash matches.
  1. The client starts the upload with the file's size and SHA-256. The upload service creates the video's row and an upload_sessions row with a fresh object key.
  2. It answers with the session URI. The URI is the credential for the bytes: unguessable, valid for one object, expiring.
  3. The client sends the file in chunks of 8 MiB. Each chunk is answered with the bytes the store holds, so after a break the client asks and continues from there.
  4. When the last chunk arrives, storage reports the finished object.
  5. The upload service checks the object's SHA-256 against the declared one. Only then does the video move to processing and its tasks get written.

The upload service handles small requests only; the 240 Gb/s of uploads go straight into object storage, which is built to take them. The deep dives test what a session URI allows and how resuming works in Google's protocol and Amazon's.

3. A Graph of Tasks, the Low Path First

Processing is many independent jobs: probe the file, check it against copyright references and the rules, and for every rung of every codec an encode and a package step. They form a graph — an encode needs the probe, a package needs its encode — and they are rows of the tasks table, which workers take as they become ready.

Step 3: processing is a graph of tasks, the low path first. Workers take ready tasks from a table, and 360p plays before 4K exists. The upload is probed; then the check (copyright references and the rules) and every encode can run at once. The 360p H.264 encode, its packaging and the check have priority 0 and gate publish, so the video plays as soon as they are done. The other 12 rungs — VP9 to 2160p, H.264 to 1080p — are packaged and join the manifest as each finishes. The tasks table at one moment: probe done; check, the 360p encode and two VP9 encodes running; packaging and publish waiting. A worker takes a task whose needs are done, lowest priority first, with a lease that runs out if the worker dies.
  • The low path goes first. The 360p H.264 encode, its packaging and the check have priority 0, and publish needs only them: the video plays while 4K is still encoding. YouTube does the same: "When you upload a video, it will initially be processed in low quality … your video will be available to stream in low quality first, on a wide variety of devices. Higher-quality videos, such as 4K or 1080p, can take more time to process."
  • Workers take tasks with a lease. A worker that dies leaves a task whose lease runs out, and another worker takes it; the dead worker's late "done" changes nothing.
  • Each rendition joins when it is ready. A renditions row appears when a rendition's segments and manifest are stored, and the manifest the player gets lists only those.

In our run of one 20-second 4K upload on four workers, this order made the video playable 7 seconds after the upload completed, against 53 seconds when tasks were taken in the order they were created; the deep dives show the schedule.

4. Watching Through Caches

A viewer's player asks the API for the video and gets the watch page with a manifest URL. From then on it fetches the manifest and the segments over plain HTTP from the nearest cache.

Step 4: segments come from the nearest cache. The API names the manifest; the bytes come from caches near the viewer. (1) The player asks the metadata servers for the video; they read it by video_id from the shards, through a cache, and return the title, the counts and the manifest URL. (2) The player fetches the manifest and the segments from the nearest cache: a cache inside the ISP's network, then an edge site in a city, then a regional site, and finally object storage, each asked only on a miss below it; each tier keeps what it fetched. (3) The player picks the rung of each segment from its buffer and throughput: 360p first, then 720p and 1080p, down to 480p when the network slows, back up after.
  • Caches in tiers. The nearest is often inside the viewer's own ISP; a miss goes to an edge site, then a regional site, and finally to object storage. Each tier keeps what it fetched, so a popular segment travels the long way once.
  • The player chooses the quality. Every segment exists in every rung; the player picks each one's rung from its buffer and the throughput it sees, so the quality follows the network.
  • Segments never change. A segment written once is cached for as long as there is room; nothing is ever invalidated because it changed. Only a video taken down must be purged from the caches.

5. Metadata and Counts

The metadata is small and read far more often than it is written.

Step 5: metadata sharded by video, counts from a log. A watch page is one shard's rows; a view is an event, counted later. The metadata servers read watch pages through a cache; a miss reads the video shards, chosen by video_id, which hold the videos, renditions and counts. A channel's list of videos is read from the channel shards, chosen by channel_id. Players send view events to the view log; a counting job validates and counts them and writes the counts into the video shards.
  • Sharded by video. The watch page reads one video by video_id, so video_id chooses the shard, and a cache in front holds the watch pages of popular videos.
  • A channel's list is kept by channel. "The latest videos of this channel" would otherwise ask every shard; channel_videos is sharded by channel_id.
  • Counts are not written per view. A view is an event in a log; a counting job validates the events, drops repeats and updates video_counts every few seconds.

6. The Whole Design

The whole design: one object store, three paths. Uploads fill it, workers turn originals into segments, caches serve them. Creators send their files in resumable chunks through the upload service's sessions into object storage; the upload service records each session in the metadata database, which is sharded by video. Workers claim tasks from the database, read the originals from object storage and write the segments back. Players get the watch page from the API and the segments from the nearest cache — a cache in the ISP, an edge site, a regional site — whose misses reach object storage. Views go from the players to a view log, through a counting job, into video_counts in the metadata database.
ComponentDoesScales by
Upload serviceOpens sessions, issues session URIs, checks the finished object's hash, writes the tasksstateless: add servers
Object storageOriginals and segments, durablythe store's own scaling; a region near each uploader
WorkersTake tasks from the table: probe, check, encode, packageadd machines; YouTube adds its own encoding chips
Metadata databaseChannels, videos, sessions, tasks, renditions, counts, sharded by video; channel lists by channeladd shards
API (metadata servers)Watch pages, manifests' URLs, video managementstateless, with a cache
CachesServe segments and manifests near the viewers, in tiersmore caches, closer to viewers
View log and counting jobCollect view events, validate them, write the countspartitions of the log

Three paths share one store and never wait for each other: uploads write originals, workers turn originals into segments, caches read segments. Each can grow or fail on its own.

7. The Life of a Video

The life of a video, playable in seven steps: from the first chunk to the first segment a viewer watches. (1) The creator starts an upload and gets a session URI from the upload service. (2) The creator sends the chunks to object storage, which reports the completed object to the upload service. (3) The upload service checks that the hash matches and writes the video's tasks to the metadata database. (4) A worker takes the 360p task and writes its segments to storage. (5) The worker marks the video playable. (6) A player gets the video from the metadata servers. (7) The player asks the nearest cache for segments; the cache fetches a miss from object storage once.
StepWhereWhat happens
1Creator's client → upload serviceStarts the upload with the size and SHA-256; gets a session URI
2Client → object storageSends the chunks; a break resumes from the bytes held; storage reports the completed object
3Upload serviceThe hash matches; the video becomes processing and its tasks are written
4WorkersTake the 360p task first; encode, package and store its segments
5Workers → metadatapublish: the video becomes playable, with 360p in its manifest; higher rungs join as they finish
6Player → APIGets the watch page and the manifest URL
7Player → nearest cacheFetches segments; the first request for a segment goes up the tiers to object storage once, and every later one is served from the cache