# How to design YouTube

Source: https://systemdesignsim.com/system-design/youtube

System design · Transcoding pipeline, object storage, CDN

Keep upload and playback as two separate paths: transcode each upload asynchronously into a ladder of renditions in object storage, and serve playback from CDN servers close to viewers. At 500 hours uploaded per minute, transcoding keeps about 150,000 cores busy and playback egress averages about 10 Tbps.

Updated October 25, 2026 · 5 min read

A teaching design of a system like YouTube, not YouTube's real architecture.

[Take the YouTube uploads challenge](https://systemdesignsim.com/challenges/youtube-uploads)

![YouTube architecture diagram](https://systemdesignsim.com/diagrams/youtube-system-design-diagram.svg)

Creators upload straight to S3 on a presigned URL and the API queues a transcoding job. Workers write segmented renditions to a media bucket that viewers stream through a CDN.

## The short version

* Video bytes go to object storage, uploaded directly as resumable multipart uploads. Metadata lives in a database.
* Transcoding is a big, steady compute job: queue it, chunk it, make it idempotent, and encode a low rendition first.
* 10 Tbps of egress can't come from one region. The CDN is the delivery system, so segments must be cacheable.
* Batch view counts through a stream instead of one row update per view.

## Clarifying questions to ask first

* Which features? (Assume upload, playback and view counts; search, comments and recommendations are out.)
* How much is uploaded and watched? (Assume 500 hours of video uploaded per minute and 1B views a day.)
* How soon must an upload be watchable? (Assume minutes is fine, but an upload must never be lost.)
* Which devices and networks? (Any device, including slow mobile networks. Assume playback starts within about two seconds and rarely stalls.)
* Exact view counts in real time? (No. A few seconds stale is fine.)

## Numbers that shape the design

Assumptions, stated out loud. The order of magnitude decides the architecture.

| Quantity            | Assumption                                                     | Result                                                               |
| ------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------- |
| Upload volume       | 500 hours of video uploaded per minute                         | ≈ 720,000 hours a day                                                |
| Original storage    | ≈ 1 GB per hour of uploaded source video                       | ≈ 720 TB a day of originals                                          |
| Transcoded storage  | the full rendition ladder adds about the same again            | ≈ 1.4 PB a day ≈ 500 PB a year, before replicas                      |
| Transcoding compute | ≈ 5 CPU-hours to encode one hour of video into every rendition | 30,000 video hours an hour × 5 ≈ 150,000 cores busy around the clock |
| Views               | 1B views a day                                                 | ≈ 11,600/s average, ≈ 35,000/s at a 3× peak                          |
| Egress              | 5 minutes watched per view at ≈ 3 Mbps                         | ≈ 110 MB per view ≈ 110 PB a day ≈ 10 Tbps average                   |

## API

```
POST /api/videos
→ { "title": "My trip", "description": "...", "size_bytes": 2147483648 }
← 201 { "video_id": "v_8f3k", "upload_url": "https://uploads.example.com/...signed", "part_size": 16777216 }

PUT {upload_url}?part=1..n            multipart, resumable
POST /api/videos/{id}/complete        → 202 { "status": "processing" }

GET /api/videos/{id}
→ 200 { "title": "My trip", "status": "ready", "views": 10432,
        "manifest_url": "https://cdn.example.com/v_8f3k/master.m3u8" }

POST /api/videos/{id}/views           → 202
```

A 2 GB file over a phone connection will be interrupted, and restarting from zero loses users. With S3 this is a presigned multipart upload, so retries are per part.

## Data model

Metadata fits PostgreSQL (RDS) sharded by video ID, or DynamoDB. Video files live in S3, keyed by video and rendition.

```
videos
  video_id        string     primary key
  owner_id        bigint
  title           text
  description     text
  status          enum       uploading | processing | ready | failed
  duration_s      int
  created_at      timestamp

renditions
  video_id        string     partition key
  rendition       string     sort key, e.g. "1080p-h264"
  manifest_key    string     object storage key of the playlist
  segment_prefix  string     object storage prefix of the segments

view_counts
  video_id        string     primary key
  views           bigint     updated in batches, not per view
```

Keep views out of the videos row. A popular video gets thousands of views a second, and that row would become a hot spot that also blocks reads of the title.

## Why transcoding is asynchronous

Transcode inside the upload request and a burst of uploads exhausts the API servers, taking the watch path down too. Accept the upload, enqueue a job and return 202. Workers scale on queue depth, and a burst becomes a longer wait, not errors. The new risk is backlog: if the queue outgrows the workers, "processing" turns into hours.

## High-level design

* The API creates the metadata row as "uploading" and returns a presigned URL. The client uploads the original into an S3 uploads bucket.
* On completion a job goes onto SQS or Kafka. Workers (FFmpeg on EC2, or AWS Elemental MediaConvert) write segmented renditions to a media bucket and set status to "ready".
* The player gets metadata from the API (cached in Redis, since one title is read millions of times), then the manifest and segments from a CDN such as CloudFront, which pulls from the media bucket on a miss. Long cache lifetimes and stable URLs stop one viral video saturating the bucket's region.

## The transcoding pipeline

* Cut the original into chunks of a few seconds at keyframes, encode them as separate jobs, then stitch. A two-hour video finishes in minutes, and a failed chunk retries alone.
* The queue delivers at least once, so write outputs to deterministic keys and a retry overwrites instead of duplicating.
* Send repeatedly failing files to a dead-letter queue.
* Encode a low rendition first and mark the video watchable, then fill in higher resolutions.

## Adaptive bitrate streaming

Each video is encoded into a ladder of renditions, say 240p to 1080p or 4K, cut into two-to-six-second segments listed in a manifest (HLS .m3u8 or DASH .mpd). The player picks each segment's quality from its measured download speed, so a viewer on a train drops to 360p instead of stalling. More renditions mean smoother playback but more storage and compute; encode the full ladder only for videos that get traffic.

## View counts and recommendations

Send view events to a stream, aggregate in a stream processor, and flush a sum per video every few seconds. The database sees thousands of times fewer writes. Recommendations are usually out of scope; if asked, they're computed offline from watch history into a per-user list in a key-value store.

## Common traps

* Publishing a manifest before its segments exist. Publish each rendition only after its outputs are durable.
* Estimating transcoding cores from views. Encoding follows uploaded duration and the ladder; playback follows egress.
* Naming outputs with only the video ID. Rendition jobs overwrite each other; include rendition and segment in the key.
* Choosing quality from the origin's bandwidth. The bottleneck is often the viewer's connection; let the player decide.

## Follow-up questions interviewers ask

* "What if a transcoding worker crashes mid-job?" The queue redelivers, and deterministic keys make the retry overwrite.
* "How do you make a two-hour video watchable quickly?" Encode chunks in parallel, low rendition first.

## Frequently asked questions

### Why not store videos in the database?+

Videos are large, immutable files read sequentially. Object storage such as S3 is cheap per gigabyte, durable and easy to front with a CDN; a database would be slow and expensive at petabyte scale.

### What is adaptive bitrate streaming?+

The video is encoded at several qualities in short segments listed in a manifest. The player measures its bandwidth and picks a quality per segment, switching down instead of stalling.

### How do you count views at scale?+

Stream view events, aggregate per video for a few seconds, and write totals in batches. That avoids a hot row per popular video.

## More system design guides

[All 76 guides](https://systemdesignsim.com/system-design)

* [Design a Netflix CDNEdge caching and the launch stampede](https://systemdesignsim.com/system-design/netflix-cdn)
* [Design a Short Video App like TikTokVideo upload, transcoding, feed retrieval and CDN playback](https://systemdesignsim.com/system-design/tiktok)
* [Design an InstagramMedia uploads, feeds, hot accounts](https://systemdesignsim.com/system-design/instagram)
* [Design a Live Streaming Platform like HotstarIPL spikes, pre-warming, panic mode](https://systemdesignsim.com/system-design/hotstar-live-streaming)
* [Fault Tolerance explainedNines, retries, circuit breakers, chaos](https://systemdesignsim.com/system-design/fault-tolerance)
* [API Design explainedAPI Design](https://systemdesignsim.com/system-design/api-design)

## Now fix it yourself.

Run the design under real traffic and see what breaks first. No signup.

[Take the YouTube uploads challenge](https://systemdesignsim.com/challenges/youtube-uploads)
