The whole course ▾

System Design · Lesson 30 of 39 · Week 7

Design YouTube: upload, transcode, stream

Updated 22 Oct 2026 · By Akshay, software engineer, India · 5 min read

500 hours of video reach YouTube every minute, and each must play smoothly on any phone, anywhere. Today: design YouTube.

The video for this lesson is coming soon.

New System Design videos go up at 6 pm. Subscribe on YouTube so you don't miss it.

Got a doubt? Ask in the comments under the video.Subscribe

The problem, in numbers

The problem, in numbers
What it must do
Upload a video of any size
Watch it on any device
Smooth on slow networks too
Count views
The numbers
500 hours uploaded every minute
= 30,000 hours of new video a
day
Each kept in about 6 qualities
Over a billion hours watched a
day
WHAT THE NUMBERS DECIDE
Bytesgoingout
dwarfeverythingelse:
theCDNisthe
design.

Week seven is case studies: famous systems, designed from scratch with everything you've learned. We start with the biggest video site in the world, and the numbers tell us where to look.

First, the requirements, kept small. Creators upload a video of any size, from a few seconds to several hours. Viewers watch it on any device: a big TV, a laptop, or an old phone. Playback must stay smooth, even on a slow, wobbly mobile network. And we count views, because creators care about little else.

Now the numbers. About five hundred hours of video are uploaded every minute: thirty thousand hours of new video every day. Each one is stored several times over, in about six qualities, from tiny to 4K. And viewers have watched over a billion hours a day for years. Watching outweighs uploading by tens of thousands to one.

So say what the numbers decide. The hard part isn't the database, or even storage. It's the bytes going out to viewers, every second of every day. Almost all of them must come from a CDN near the viewer, from lesson nine, never from our own servers. Everything else in the design exists to feed that CDN the right files.

Getting the video in

Getting the video in
Creator
app
Upload
service
Videos DB
title, state,
owner
Object
storage
raw uploads
new video
1
state: uploading
2
parts,
resumable
3
THE ORIGINAL IS PRECIOUS
Keeptheoriginalupload
forever:everyfuture
formatismadefromit.

Uploading first. It's last week's lesson, at a much bigger scale.

The creator app tells the upload service about a new video. The service saves a row in the videos DB: the title, the owner, and a state, uploading. Then it hands back presigned URLs, and the app sends the file straight to object storage, in parts, resumable, exactly like the menu videos in lesson twenty-nine. A three-hour lecture over a hotel's wifi survives every drop, and the bytes never touch our servers.

One rule: keep the original upload, untouched. New phones, new screens and better compression keep arriving, and every new format has to be made from the best copy there is. Re-encoding an already compressed copy would lose quality every time.

The transcoding pipeline

The transcoding pipeline
Each upload becomes
->
About 6 qualities, 144p to 4K
->
Short segments, a few seconds each
->
Thumbnails and captions
Getting the video in
Creator
app
Upload
service
Videos DB
title, state,
owner
Object
storage
raw uploads
new video
1
state: uploading
2
parts,
resumable
3
Transcode
queue
Transcode
workers
Object
storage
segments, 6
qualities
upload
done
4
one segment
each
5
renditions
6
state:
ready
7
THE ORIGINAL IS PRECIOUS
Keeptheoriginalupload
forever:everyfuture
formatismadefromit.

The raw upload can't be played by most devices as it is. It has to be transcoded: converted into the formats and sizes viewers need. That's heavy work.

When the upload completes, the video is cut into short segments, a few seconds each, and every segment becomes a job on a transcode queue. Hundreds of transcode workers take segments in parallel, each producing six qualities, from 144p to 4K, and save them back to object storage. When the last segment is done, the video's state becomes ready. A one-hour video finishes in minutes, because a hundred workers each handled a small piece.

So each upload becomes: about six qualities, so every screen and network gets a version that suits it. Thousands of short segments, a few seconds each, which is what makes the next part possible. And thumbnails and automatic captions, made by other workers from the same queue. It's lesson twenty-nine's job queue, multiplied by five hundred hours a minute.

Adaptive streaming

Adaptive streaming
How playback works
1
Download a playlist: every quality
2
Fetch a few seconds at a time
3
Measure the download speed
4
Switch quality at the next segment
ADAPTIVE BITRATE STREAMING
HLSandDASH:small
segmentsinmanyqualities,
andtheplayerchooses,
everyfewseconds.

Why cut videos into segments at all? Because of how a modern player watches.

The player first downloads a small playlist: a list of every quality, and every segment's address. Then it fetches a few seconds of video at a time, staying a little ahead of what you're watching. It measures how fast each segment arrived. And if the network gets slower, it switches to a lower quality from the next segment on. You see the picture get a bit softer for a moment, instead of a spinning wheel.

This is adaptive bitrate streaming, and its common formats are called HLS and DASH. Notice the clever part: the server doesn't decide anything. It just stores files. The player, which knows its own network best, chooses the quality every few seconds. That's also why every segment is a plain file a CDN can cache.

Serving a billion hours

Serving a billion hours
Counting views
1
Never one database write per view
2
View events into Kafka
3
Counted in batches, every minute
Getting the video in
Creator
app
Upload
service
Videos DB
title, state,
owner
Object
storage
raw uploads
new video
1
state: uploading
2
parts,
resumable
3
Transcode
queue
Transcode
workers
Object
storage
segments, 6
qualities
upload
done
4
one segment
each
5
renditions
6
state:
ready
7
Viewer
CDN edge
near each
city
segment
42, 720p
only on a miss
THE ORIGINAL IS PRECIOUS
Keeptheoriginalupload
forever:everyfuture
formatismadefromit.

Now the part the numbers warned us about: getting those segments to viewers.

The viewer's player fetches every segment from the nearest CDN edge, which goes back to object storage only on a miss. Popular videos are watched millions of times, so their segments stay cached at every edge, and storage barely notices them. The long tail, millions of videos with a handful of views each, is served from a few regional caches, or straight from storage, which is cheaper than keeping everything everywhere.

And counting views. Never update one database row per view: a viral video is the hot row from mock interview one, with millions of writes queued behind each other. Instead, players send view events into Kafka, and a counting job adds them up in batches, every minute, writing one total per video. The count on the page is a minute behind, and nobody minds. Lesson thirty-seven designs this kind of counting properly.

In the interview

In the interview
SAY THIS IN THE INTERVIEW
Resumableuploadsto
storage,segment-parallel
transcoding,adaptive
streaming,servedfromaCDN.
Follow-ups to expect
->
Why cut videos into
segments?
->
Popular videos versus the long
tail?
->
How do you count views?
THE COMMON MISTAKE
Servingvideofrom
yourownservers,or
onesinglefilefor
everydevice.

Design YouTube, or Netflix, is one of the most common system design questions of all.

Say it like this: resumable uploads straight to object storage; a transcoding pipeline of queues and workers, splitting each video into segments and qualities; adaptive bitrate streaming with HLS; and every segment served from a CDN. Then say views are counted asynchronously, through a stream.

Then expect these. Why cut videos into segments? Parallel transcoding, quality switching mid-video, and files a CDN can cache. Popular videos versus the long tail? Cache the popular ones everywhere, and serve the rarely watched ones from fewer places. And how do you count views? Events into a stream, counted in batches, never one write per view.

The common mistake is serving video from your own servers, or storing one file for every device. Either one falls over long before a billion hours a day. The CDN and the player do the heavy lifting.

Quick check

Quick check
?
A viewer's network drops
from 20 to 2 Mbps
mid-video. What happens?
Lower quality from the next
segment: the player switches
down instead of stalling.
?
Why cut a video into
segments before transcoding
it?
Parallel work: many workers
transcode small pieces at once,
so long videos finish in minutes.
Remember
Uploads: resumable, straight
to storage
Transcode in parallel segments
Adaptive streaming from a
CDN
Quick check

A viewer's network drops from 20 to 2 Mbps mid-video. What happens?

Show the answer

Lower quality from the next segment: the player switches down instead of stalling.

Quick check

Why cut a video into segments before transcoding it?

Show the answer

Parallel work: many workers transcode small pieces at once, so long videos finish in minutes.

Remember: uploads are resumable, straight to storage. Videos are transcoded in parallel segments, into several qualities. And adaptive streaming from a CDN lets every player choose its own quality. Tomorrow: files that stay in sync on every device you own.

Practise with flashcardsYour progress stays on this device.
New System Design videos at 6 pm

Lessons on weekdays, the week's revision on Saturday, a mock interview on Sunday.