System Design: YouTube (Walnut Tube: Resumable Uploads, Parallel Encoding, Adaptive Playback, Live Streaming, Live Chat, View Counting, Recommendations, Search)
We design a video sharing service, like YouTube, and call it Walnut Tube.
Anyone can upload a video, from a 15-second clip to a film several hours long. Anyone can watch, on a phone, a laptop or a TV. Creators can also go live, and their viewers chat while they watch.
An interviewer who asks "design YouTube" expects all of it:
- uploads, processing and playback;
- live streaming and live chat;
- views, likes and comments;
- the home feed and search.
This post covers each one, as deep as an interview goes.
As in any system design interview, the numbers are assumptions for planning. Every number here is our own assumption, and the design is our own.
All times are on Saturday 7 November 2026. They are in US Central Time, the time of Chicago and Austin, unless a line says otherwise. Portland is two hours behind.
1. Requirements
1.1 What we are building
Walnut Tube does four jobs:
- Take videos in. Receive files up to 256 GB from creators on any network, even when it drops. Make the versions every screen needs, check the video for harmful content, and publish it.
- Play them. Start a video in under a second, from a server near the viewer. Change its quality as the viewer's network changes, without stopping.
- Go live. Take a creator's live stream, and show it to any number of viewers a few seconds behind, with live chat.
- Help people find videos. Count views and likes honestly, keep comments, and fill each person's home page and search results.
The story, one Saturday:
- 13:10. In Portland it is 11:10. Grace Kim, a filmmaker, starts uploading her 2-hour documentary from hotel Wi-Fi. The file is 18 GB.
- 13:31 and 13:52. The Wi-Fi drops twice, for 3 minutes and then 2. Each time the upload goes on from the last part the server stored.
- 14:15. The last byte arrives. Six minutes later, at 14:21, the documentary plays in three sizes. They are 360p, 720p and 1080p. The sharper versions follow by 15:40.
- 18:30. Daniel Reyes watches it on a train near Chicago. His network falls from 8 to 1.5 Mbit/s. The picture drops from 1080p to 480p, and it never stops. Mbit/s means millions of bits a second.
- 19:00. In Austin, Chloe Martin starts a live cooking stream for her 2,000 regular viewers.
- 19:06. A celebrity shares her stream. By 19:16, 400,000 people are watching live. Her chat gets 3,000 messages a second.
- 19:20. In Denver, Mia Torres asks in the chat what oil Chloe uses. Chloe sees the question and answers it on camera 6 seconds later.
- 20:30. Chloe ends the stream. At 20:41 the recording plays as a normal video.
- 20:50. Chloe posts a 30-second clip from the stream. It gets 10 million views in its first hour.
- 21:00 to 23:00. A bot farm called ViewForge, which sells fake views, tries to add 2 million views to a music video.
- 22:40. Our US West region fails. Sarah Lee, our on-call engineer, watches traffic move to the other regions within about a minute.
What happens to each person:
- Grace's upload never starts over. A drop costs at most the one 16 MB part on the wire.
- Daniel's video changes quality but never pauses.
- Chloe's viewers stay 3 to 8 seconds behind her camera, even at 400,000 viewers. Mia's question reaches Chloe's screen within 2 seconds.
- Her recording and her clip play like any other video.
- About 92% of ViewForge's fake views are never counted, and 5% more are removed the next morning.
- In the region failure, most viewers see no pause, because their buffer covers the move. No upload starts over.
The hard part has four sides:
- About 700 hours of video arrive every minute, and each needs many versions, fast.
- At the busiest moment, 208 million screens play at once: 625 Tbit/s, trillions of bits a second.
- A live stream must reach every viewer seconds after the camera, with no time to prepare.
- Counts, feeds and search must work at this size, and must not be fooled by bots.
1.2 Words we use
Words used in only one place are explained there. Each word below is used all through the post.
Video files.
| Word | Meaning here |
|---|---|
| Original | The file exactly as the creator uploaded it |
| Part | A 16 MB piece of an upload. MB means megabytes; GB, TB, PB and EB are each 1,000 times the one before |
| Encode | Turn video into a smaller form for one screen size. A program that does it is an encoder |
| Rendition | One encoded version of a video, at one size and bitrate, such as 720p at 2 Mbit/s. 720p means 720 rows of pixels |
| Bitrate | How many bits a video uses each second of playing |
| Codec | The method of encoding. H.264 is the old method every device plays. AV1 is newer and about 40% smaller, but takes about 4 times the work to encode |
| Ladder | The set of renditions of one video. Ours has 12: six sizes from 144p to 1080p in H.264, and six from 360p to 2160p, which is 4K, in AV1 |
| Piece | A few minutes of a video, encoded on its own so many encoders can work at once |
| Segment | 2 seconds of one rendition, the unit a player downloads |
| Manifest | A small file that lists a video's renditions and segments |
Playback.
| Word | Meaning here |
|---|---|
| Player | The code in the app or web page that downloads segments and shows them |
| Adaptive bitrate | The player picks the next segment's rendition from how fast the last ones arrived |
| Buffer | Seconds of video the player has downloaded but not shown yet |
| CDN | Content delivery network: servers in many cities that keep copies of files near viewers |
| Edge | A CDN server near the viewer, often inside the viewer's internet provider |
| Shield | A bigger CDN site in front of our storage. Edges ask the shield, and only the shield asks storage |
| Signed URL | A web address with an expiry time and a signature, so an edge can check access without asking our services |
Live.
| Word | Meaning here |
|---|---|
| Ingest | Our servers that receive a creator's live stream |
| Live delay | How far a viewer's picture is behind the creator's camera, such as 5 seconds |
| Recording | The live stream saved as a normal video when it ends |
| Live chat | Messages viewers send during a live stream, shown to everyone watching |
The system.
| Word | Meaning here |
|---|---|
| Region | One of our six groups of data centers, such as US West in Oregon |
| Zone | One building or group of buildings inside a region, with its own power |
| Shard | One slice of a store, holding some keys. Each shard has copies in three zones |
| p50, p99 | p50 is the time half of all requests finish within. p99 is the time 99 of every 100 finish within |
| Design peak | The busiest moment we plan for: 2.5 times the daily average |
| Lease | A claim that ends by itself after a set time unless it is renewed |
| Outbox | A table where a service writes an event in the same transaction as its own change. A relay sends the event on, so the change and its event cannot disagree |
IDs in this post. Every ID below is made up.
| ID | What it names | Example from the story |
|---|---|---|
| u_3301 | A user ID | Grace Kim |
| u_5180 | A user ID | Chloe Martin |
| u_7724 | A user ID | Daniel Reyes |
| u_6402 | A user ID | Mia Torres |
| v_7K2P | A video ID | Grace's documentary |
| up_g18 | An upload ID | The upload of Grace's documentary |
| ls_C900 | A live stream ID | Chloe's cooking stream |
| v_C9RC | A video ID | The recording of Chloe's stream |
| v_9Q4C | A video ID | Chloe's 30-second clip |
| v_M3X1 | A video ID | The music video ViewForge targets |
1.3 Every kind of request and change
Walnut Tube handles more than the story shows. This table lists every kind. Each part it names is explained where it first appears in the design.
| Kind | What it is | How big or how often | Part that handles it | Outside company that takes part |
|---|---|---|---|---|
| Upload | A video sent in 16 MB parts | 20 million videos a day | Upload service, Media store | none |
| Encode | Renditions made from the original | 60 million video minutes a day | Encode queue, Encoders | none |
| Safety check | Harmful content and copyright | every video | Safety service | none |
| Watch | A player downloads segments | 208 million at once at the design peak | CDN edges and shields | Internet providers host our edges |
| Watch page | Title, counts, a play token and signed URLs | about 2.9 million a second at the design peak, one per view start | Video service | none |
| Live stream | A creator streams from a camera or phone | 300,000 at once at the peak | Ingest servers, Live encoders | none |
| Live chat | A message during a live stream | Chloe's: 3,000 a second | Chat service | none |
| View and like | A counted view, a like | 100 billion view starts and 4 billion likes a day | Event log, View counter | none |
| Comment | A comment on a video | 150 million a day | Comment service | none |
| Home feed | The videos on a person's home page | 6 billion a day | Feed service, Ranking service | none |
| Search | A typed search | 3 billion a day | Search service | none |
| Notification | "A channel you follow uploaded" or "is live" | billions a day | Notification service | Apple and Google send the pushes |
1.4 Functional requirements
- Upload. Accept videos up to 256 GB and 12 hours. An upload goes on after a dropped network, from the last stored part.
- Process. Make every rendition each screen needs. The first versions must play soon after upload; the sharper ones may come later.
- Check. Check every uploaded video for harmful content and copyrighted material before it is public. Check a live stream while it runs.
- Play. Start a video fast on any device, and change quality as the network changes, without stopping.
- Live. Take a live stream from a creator and play it to every viewer a few seconds behind. Keep it as a video when it ends.
- Live chat. Show viewers' messages to everyone watching a live stream, even at hundreds of thousands of viewers.
- React. Count views, likes and comments, and do not count fake views.
- Discover. Fill each person's home page with videos they are likely to watch, and answer searches.
- Notify. Tell followers when a channel uploads or goes live.
Out of scope: ads, paid memberships and how creators are paid. How the recommendation models are trained is out of scope too; how they are served is in scope.
1.5 Non-functional requirements
- Start time. A video starts playing in 1 second at p50 and 2 seconds at p99.
- No stalls. Playback pauses to load for less than 0.5% of watch time.
- First versions. A video plays within 10 minutes of its last uploaded byte, for videos up to 2 hours.
- Upload safety. A part is confirmed only after it is stored in three zones.
- Live delay. Viewers are 3 to 8 seconds behind the creator's camera, at any number of viewers.
- Live chat. A message reaches viewers within 2 seconds.
- Counts. A view count is at most 1 minute behind. Fake views are removed within a day.
- Feeds and search. The home page and search answer in 300 ms at p99.
- Availability. 99.99% of plays succeed in a month. A region failure moves viewers within 60 seconds.
1.6 The numbers
These are rough sums, the kind a candidate does at a whiteboard in a few minutes. Every number is our own assumption.
Walnut Tube has 1.2 billion daily viewers. We plan for the design peak, 2.5 times the daily average, because the evening is busy everywhere and big events add more.
| Number | How we get it | Result | What it decides |
|---|---|---|---|
| Streams at once | 1.2 billion viewers × 100 minutes a day = 120 billion minutes. ÷ 1,440 minutes in a day = 83 million at once. × 2.5 at the design peak | 208 million at the design peak | Playback must never touch our services per segment; the CDN serves it |
| Bytes out | 208 million streams × 3 Mbit/s on average | 625 Tbit/s | Edges inside internet providers, so most bytes never cross the open internet |
| Upload minutes | 5 million long videos × 11 minutes + 15 million short ones × 20 seconds = 60 million minutes a day. ÷ 1,440 | About 700 hours every minute | Uploads go straight to object storage in parts |
| Upload bytes | Originals average 10 Mbit/s = 75 MB a minute. × 60 million minutes | 4.5 PB a day | Object storage, reached through the Upload service, never through the API servers |
| Encoding work | The H.264 ladder costs 0.5 encoder minutes per video minute. 0.5 × 60 million = 30 million encoder minutes a day. ÷ 1,440 = 20,800 encoders busy on average. × 2.5 at the design peak | About 52,000 encoders busy at the peak | A queue with priorities |
| AV1 work | AV1 costs about 2 encoder minutes per video minute, 4 times H.264. Only 4K originals and videos past 1,000 views get it: about 10% of minutes. 0.1 × 60 million × 2 = 12 million a day. ÷ 1,440 | About 8,300 more encoders on average | AV1 runs in quiet hours, and only where its 40% saving pays for the work |
| Live | 300,000 live streams at once × 6 Mbit/s in = 1.8 Tbit/s. Their 5 renditions cost 0.5 encoder minutes per minute: 150,000 encoders. Add 20% spare and 3,000 second encoders for streams above 10,000 viewers | About 183,000 live encoders | Live encoding is kept apart from the upload queue: it cannot wait |
| Live chat | Chloe's chat: 3,000 messages a second × 400,000 viewers | 1.2 billion deliveries a second if sent one by one | Each viewer gets one batch a second, of at most 50 messages |
| Views | 100 billion view starts a day ÷ 86,400 = 1.16 million a second. × 2.5 | 2.9 million a second at the peak | Views go through a log and are counted in batches, never as one database write each |
| Playback events | 208 million streams each send one batch of events every 30 seconds: 6.9 million a second. Add 2.9 million view starts | About 9.8 million events a second at the peak | A collector that only adds events to a log, never to a database |
| Home feeds | 6 billion a day ÷ 86,400 × 2.5. Each ranks about 1,000 candidate videos | 174,000 feeds a second at the peak | A cheap ranking cuts 1,000 to 200, and only those 200 get the heavy model |
| Storage | All H.264 renditions of one minute add up to about 62 MB. × 60 million minutes = 3.7 PB of renditions. Originals 4.5 PB + renditions 3.7 PB = 8.2 PB a day. × 1.5 for erasure coding | About 12 PB a day, about 4.5 EB a year | Cold storage for videos nobody watches, and fewer renditions for them |
Erasure coding cuts each file into 2 data pieces and 1 parity piece, and puts one piece in each of three regions. Any two pieces rebuild the file, so a lost region loses no file. It stores 1.5 times the data.
What these numbers tell us. Each of the four jobs has its own hard number:
- 625 Tbit/s of playback, which only a CDN inside internet providers can carry;
- 52,000 encoders busy at the peak, kept busy by a queue with priorities;
- about 183,000 live encoders that cannot wait for anything;
- 1.2 billion chat deliveries a second for one stream, unless messages are batched.