Black Friday 50% off any plan, for life Ends Nov 30

System design

Design YouTube

YouTube lets anyone upload a video and lets everyone else watch it on a phone, a laptop or a TV, on any connection. A million videos arrive every day, some of them 10 GB, and 100M people watch videos every day.

The hard parts are getting very large files in over unreliable connections, turning each upload into a set of files that plays well at every bandwidth, and serving terabits a second without stalling. This write-up follows one video, Jane's 12-minute sourdough recipe, from her laptop to S3, through the transcoding pipeline, and out to John's phone on a train.

Now draw it yourself, cold

You can nod along to a finished design and still freeze five minutes into the real round. In the 14-day free trial you draw this system yourself while an interviewer asks questions and grades every decision.

14-day free trial. Cancel anytime with one click.

I have an account

Understanding the problem

Functional requirements

  1. Users can upload videos of up to 10 GB.
  2. Users can watch videos, on any device and connection.

Questions worth asking, with the answers you will usually get:

  • How long until a new video can be watched? A few minutes is fine. Processing happens after the upload, and the uploader sees "Processing" meanwhile.
  • What devices and connections? Phones, laptops and TVs, on anything from 1 Mbps mobile data to gigabit fibre. Playback has to adapt as the connection changes.
  • How popular is the average video? Very uneven. Most videos get a handful of views; a few get millions in a day. Viewers watch about 5 videos a day each.
  • Do we show view counts? Yes, and they may lag by a few seconds.
  • Search? A stretch goal if there is time: finding videos by title and description.

Out of scope: recommendations, comments, likes, subscriptions, live streaming, ads and content moderation.

Non-functional requirements

  1. Never lose an upload. Once the upload completes, the video survives any machine or disk failure.
  2. Fast, smooth playback. The first frame shows within 2 seconds, and the video stalls for less than 1% of watch time, on a connection that changes under it.
  3. Large uploads survive bad connections. A dropped connection during a 10 GB upload costs only the parts in flight, at most 64 MB, not the whole file.
  4. New videos play within minutes. A typical 10-minute video is watchable within 5 minutes of finishing its upload.
  5. Scale. 1M uploads a day, 100M daily viewers, 500M views a day.

Durability and scale shape the design most. Durability means the original goes into object storage and stays there. Scale means the bytes never pass through our own servers in either direction: uploads go straight to S3, and views come from a CDN. Metadata and view counts can be eventually consistent.

Back-of-the-envelope estimation

Round hard, and keep the numbers that change a decision.

Uploads. Assume the average upload is 10 minutes long and 500 MB.

uploads:   1M / day ÷ 86,400 s ≈ 12 / s, peak (2×) ≈ 25 / s
ingest:    1M × 500 MB = 500 TB / day
           500 TB ÷ 86,400 s ≈ 5.8 GB / s ≈ 46 Gbps

Storage. Every upload becomes a ladder of five renditions, which this write-up calls rungs:

1080p 5.0 + 720p 2.6 + 480p 1.2 + 360p 0.8 + 240p 0.4
  = 10 Mbps for one second of video, every rung together

per video:  600 s × 10 Mbps = 6,000 Mb = 750 MB
per day:    1M × 750 MB = 750 TB of renditions
          + 500 TB of originals = 1.25 PB / day
per year:   1.25 PB × 365 ≈ 460 PB

Objects. Every rung is cut into 4-second segments.

segments per video:  600 s ÷ 4 s = 150 per rung × 5 = 750
                     + 150 audio segments = 900
per day:             1M × 900 = 900M new objects ≈ 10,400 PUTs / s

Transcoding. Assume the whole ladder costs about 5 CPU-seconds per second of video.

1M × 600 s × 5 = 3B CPU-seconds / day
3B ÷ 86,400 s ≈ 35,000 cores busy, peak ≈ 70,000
               ≈ 1,100 machines of 32 cores, 2,200 at peak

Views and egress. Assume an average view watches 6 minutes, at an average of 3 Mbps across phones and TVs.

views:        100M × 5 = 500M / day ≈ 5,800 / s
watch time:   500M × 360 s = 180B s / day
concurrent:   180B ÷ 86,400 ≈ 2.08M viewers, peak ≈ 4.2M
egress:       2.08M × 3 Mbps ≈ 6.25 Tbps, peak (2×) ≈ 12.5 Tbps
segment GETs: 2.08M × 2 (video + audio) ÷ 4 s ≈ 1M / s,
              peak ≈ 2M / s

Metadata. A video's row is about 2 KB.

rows:   1M / day × 2 KB = 2 GB / day ≈ 730 GB / year
reads:  one per view ≈ 5,800 / s, peak ≈ 12,000 / s
QuantityEstimateWhat it decides
Ingest46 GbpsUploads go straight to S3, never through an API server
New storage1.25 PB / dayObject storage; originals move to a cold tier after processing
Transcode compute~35,000 coresA shared worker fleet fed by a queue, scaled on its depth
Peak egress12.5 TbpsA CDN with a mid-tier; origin serves about 1% of the bytes
Segment GETs2M / s at peakSegments are static files that any cache can serve
View counts5,800 / s, one video up to 50,000 / sCounted in batches, never a row update per view
Metadata730 GB / year, 12,000 reads / sOne Postgres with replicas and a Redis cache; no sharding yet

See it in the flythrough19 · At scale

Core entities

  • User: an uploader or a viewer.
  • Video: the metadata row. Id, owner, title, description, duration, status (uploading, processing, ready or failed), the multipart uploadId, the manifest URL and the view count.
  • Original: the uploaded file, one object in S3.
  • Rendition: one rung of the ladder (resolution and bitrate) and its playlist.
  • Segment: 4 seconds of one rung, one object in S3.

The split that matters: the bytes live in S3, and only facts about them live in the database. A video row never holds a byte of video.

API

POST /videos
  { title, description, sizeBytes: 1200000000 }
→ 201 { videoId: "v_8Kq2", uploadId, partSize: 16000000, partCount: 75 }
→ 422 if sizeBytes is over 10 GB

POST /videos/{id}/parts          { parts: [ { part: 1, sha256 }, … ] }
→ 200 { urls: { 1: <presigned PUT URL>, … }, expiresIn: 3600 }

GET  /videos/{id}/parts
→ 200 { uploaded: [ { part: 1, etag }, … ] }

POST /videos/{id}/complete       { parts: [ { part: 1, etag }, … ] }
→ 202 Accepted
→ 409 { missing: [52, 53] }

GET  /videos/{id}
→ 200 { title, owner, durationS, status, manifestUrl, views }
→ 404

POST /videos/{id}/views          { sessionId, watchedS }
→ 202

Three choices to say out loud. The API never carries video bytes: it hands out presigned URLs, and the browser sends parts straight to S3. Complete answers 202, not 200, because the video is accepted but not ready: processing runs afterwards, and the client polls GET /videos/{id} or is notified. Playback is not an endpoint: manifestUrl points at the CDN, and the player fetches everything else from there.

High-level design

Start with the smallest design that works. Very large files, fast processing and terabits of egress come in the deep dives.

1. Users can upload videos

  1. Create. The browser calls POST /videos. The upload service writes a Video row to Postgres with status = uploading, starts an S3 multipart upload, and returns the video id and the part size.
  2. Upload. The browser asks for presigned URLs and PUTs each part straight to S3. Each URL is scoped to one part of this upload, for one hour. The 1.2 GB never touches our servers.
  3. Complete. When every part is in, the browser calls complete. The upload service tells S3 to join the parts into one object.
  4. Hand off. S3 publishes an ObjectCreated event to a queue. The processing pipeline takes it from there and moves the row to status = processing.

See it in the flythrough02 · Ask for parts

See it in the flythrough03 · Straight to S3

Why let S3's event start processing, rather than the upload service after it completes? Because the object's existence is the trigger. If the upload service crashes between completing the upload and telling anyone, the event is still published. S3 events are delivered at least once, so the handler starts a workflow whose id is the video id. The workflow engine refuses a second workflow with the same id, so a duplicate event does nothing. The handler acknowledges the event only after the workflow exists, so a handler that crashes first sees the event again. The workflow's first step moves the row to processing.

See it in the flythrough05 · Complete

2. A video becomes watchable

The original is one big file at one bitrate, in whatever format the camera used. A phone on a train cannot play a 13 Mbps 1080p file, and a browser may not play the format at all. Processing turns it into a ladder: the same video at five resolutions and bitrates, each cut into 4-second segments, plus playlists that list them.

The smallest version is one transcoding worker that takes the event from the queue, downloads the original, encodes each rung, uploads the segments and playlists to S3, and sets status = ready. It works, and it is far too slow for a long video. Deep dive 2 fixes it.

3. Users can watch videos

  1. Metadata. John's player calls GET /videos/v_8Kq2. The video service reads the row from Redis, or from Postgres on a miss, and returns the title and the manifest URL.
  2. Manifest. The player fetches the master manifest from the CDN. It lists the five rungs with their bitrates and resolutions, and where each rung's playlist is.
  3. Segments. The player picks a rung, fetches that rung's playlist, then the segments one after another. Playback starts after the first segment, about 4 seconds of video, not after the whole file.
  4. Adapt. The player measures every download and picks the rung for the next segment.

See it in the flythrough11 · Metadata

See it in the flythrough14 · Manifest first

Deep dives

1. How do you upload a 10 GB file reliably?

A 10 GB upload at 20 Mbps takes over an hour. Over an hour, a laptop sleeps, Wi-Fi drops and a phone switches networks.

BadOne POST through the API servers

The browser sends the whole file as one request body to an API server, which streams it on to S3. It is the first thing most people draw, because the upload then uses the same servers and auth as every other call. At this problem's numbers it fails twice. The API fleet now carries all 46 Gbps of ingest, about 100 Gbps at the peak. An average 500 MB upload at 20 Mbps takes 200 seconds, so at the peak of 25 uploads a second about 5,000 requests are open at once, each holding a connection and a worker that only copies bytes. And one request cannot resume. A 10 GB file takes over an hour, and when Jane's laptop sleeps at 9 GB, the server sees a broken body and throws it away. She starts again from zero.

GoodOne presigned PUT straight to S3

The upload service returns one presigned URL, and the browser PUTs the whole file straight to S3. The instinct is right: the 46 Gbps leaves the API fleet, and the service only signs a URL and writes a row. Two limits break it. S3 refuses a single PUT over 5 GB, so the 10 GB file this section is about cannot be sent this way at all. And a PUT is still one request. If Jane's Wi-Fi drops 1 GB into her 1.2 GB upload, S3 discards the partial body and she sends all 1.2 GB again, another 8 minutes at 20 Mbps. On a phone that changes networks every few minutes, a large upload may never finish.

GreatA multipart upload with presigned parts

  • Parts. The file is cut into 16 MB parts: 75 for Jane's 1.2 GB, 625 for a 10 GB file. S3 allows up to 10,000 parts, each at least 5 MB except the last.
  • In parallel. The browser sends 4 parts at a time. It hashes each part before asking for its URL, and the SHA-256 is signed into the URL, so S3 rejects a part damaged in transit and returns an ETag for a good one.
  • Resume. Jane's Wi-Fi drops at part 52. When it comes back, the browser calls GET /videos/v_8Kq2/parts; the upload service asks S3 which parts it has (ListParts) and answers 1 to 51 with their ETags. The browser sends 52 to 75 only. S3 is the record of what arrived, so there is no separate table to keep in step; the browser completes with its own list, and ListParts is how it rebuilds that list after a restart.
  • Survive a closed tab. The browser keeps the video id and upload id in IndexedDB under a fingerprint of the file: its name, size and last-modified time. Picking the same file again resumes the upload.
  • Expiry. Presigned URLs last an hour; the browser asks for more as it needs them. An S3 lifecycle rule aborts multipart uploads 7 days after they started, so abandoned parts stop costing money. A resume after that finds no upload and starts again.

See it in the flythrough04 · Resume

What a senior candidate adds:

  • Complete is the commit point. Until CompleteMultipartUpload succeeds there is no object, and nothing downstream starts. Before calling it, the upload service checks the list against the upload: 75 parts, numbered 1 to 75, adding up to the declared size. If any are missing, it answers 409 with their numbers and does not call S3.
  • Durability comes from S3. S3 stores each object across several facilities. The original is kept after processing, moved to a cheaper cold storage class, so the video can be transcoded again with a new codec or to fix a bad encode.
  • Part size is a trade. Smaller parts lose less on a drop, larger parts mean fewer requests. At 16 MB with 4 in flight, a drop costs at most 64 MB, under 26 seconds of a 20 Mbps upload.

2. How do you transcode fast enough?

The estimate says about 5 CPU-seconds per second of video for the whole ladder. A 2-hour upload is 7,200 seconds of video.

BadThe whole file on one machine

One worker takes the event, downloads the original and runs one encoder per rung. It is the simplest pipeline, and for a 30-second clip it is fine. For a long video the work is serial. At production-quality settings the 1080p rung needs about 2.5 CPU-seconds per second of video, and one encoder process keeps only a few cores busy, so it runs at about real-time speed: a 2-hour upload is not watchable for about 2 hours. Nothing is saved along the way, so a worker that crashes at 1 hour 50 minutes starts the whole film again. And each film holds a 32-core machine for hours while short clips wait in the queue behind it.

See it in the flythrough06 · Bad: one machine

GoodOne job per rung, in parallel

Five workers each take one rung of the whole file and encode it at the same time. The rungs are independent, so this looks like free parallelism, and it does help the low rungs: 240p is a small fraction of 1080p's work and finishes long before it. But the 1080p job is still one encoder reading the file from start to end. At about real-time speed, a 2-hour film still waits about 2 hours for its top rung, and a crash near the end still loses that whole rung. A video can never use more than five workers, however many of the fleet's 35,000 cores are idle.

GreatA DAG of chunk-level tasks

An orchestrator (Temporal, AWS Step Functions or a job table of your own) runs one DAG per video:

  1. Probe the original: duration, resolution, codecs. Skip rungs above the source's resolution.
  2. Split it at its keyframes into chunks of about 4 seconds, without re-encoding. Jane's 12 minutes become 180 chunks.
  3. Transcode every chunk at every rung as its own task: 180 × 5 = 900 tasks. Each starts its output with a keyframe, so every rung's segments begin at the same timestamps, and the player can switch rungs at any segment boundary.
  4. Audio is one task over the whole track, encoded once and packaged as its own segments that every rung shares. Cutting audio at chunk boundaries can leave audible clicks.
  5. Thumbnails are one more task, a few frames picked from the original.
  6. Package. When every task has finished, the packager writes a playlist per rung and the master manifest, and the orchestrator sets status = ready.

See it in the flythrough07 · Great: in parallel

Workers take tasks from a queue. A 4-second 1080p task takes about 10 CPU-seconds, so with 2,000 free cores, the 2-hour film's 9,000 tasks finish in well under a minute of encoding, and the whole DAG in a few minutes. Jane's 900 tasks take seconds.

The segments are written as CMAF (fragmented MP4) files, which both HLS and DASH can point at. The packager writes an HLS playlist (.m3u8) and a DASH manifest (.mpd) over the same segment files, so one copy of the bytes serves Apple devices and everything else.

See it in the flythrough08 · Ladder and manifest

What a senior candidate adds:

  • Tasks are idempotent. A task's output key is fixed by its inputs: v_8Kq2/720p/seg-00031.m4s. A worker that crashes mid-task has its task redelivered when the queue's visibility timeout runs out, and the retry overwrites the same key. A partial write is replaced by the retry.
  • Retries, then failure. A task that fails three times fails the video: status = failed, and the uploader is told. A corrupt original should not be retried forever.
  • Fan-in. The orchestrator counts finished tasks for the video, 900 of 900, before packaging. That count lives in the orchestrator's state, not in a worker's memory.
  • Priorities. A 30-second clip should not wait behind a feature film. Short videos and big channels go to a higher-priority queue.
  • Watchable early. Give the 1080p tasks a lower priority, publish 240p to 720p as soon as they finish, and add 1080p when it finishes. Viewers can start minutes earlier. The master manifest then changes, so the CDN caches it for seconds, not days; segments never change and are cached for as long as it likes.
  • Chunks need not equal segments. Real pipelines often transcode 30-second chunks, which costs less per-task overhead and encodes a little better, and let the packager cut 4-second segments. The design does not change.

3. How does playback start fast and never stall?

John is on a train. His bandwidth swings from 20 Mbps at a station to about 1.5 Mbps in a tunnel.

BadDownload one MP4 file

The player downloads the original, or one large MP4, and plays it as it arrives. A plain <video src> tag does exactly this, so it looks like no work at all. On John's train it fails both ways. Give him the 5 Mbps 1080p file, and in the tunnel at 1.5 Mbps the download brings in 0.3 seconds of video for every second he watches. A 30-second buffer runs out in about 43 seconds and the video stalls. Give him a low bitrate to be safe, and he watches 240p at the station on 20 Mbps. The file has one bitrate, so the player has no way to change quality mid-video.

GoodA few MP4 files at different bitrates

Encode a few MP4 files, say 1080p, 720p and 360p, and have the player run a quick speed test at the start and pick one. It is a real step up: a fast connection gets 1080p and a slow phone gets 360p. It breaks the first time the connection changes, and on a train that is every few minutes. John starts at 1080p on 20 Mbps at the station. In the tunnel his link falls to 1.5 Mbps, and the 5 Mbps file stalls within a minute, as above. To switch, the player has to open a different file and seek to the same moment, which needs an index of each file's byte offsets and costs a visible pause every time the bandwidth moves.

GreatAdaptive bitrate streaming over segments

  • Start low. The player reads the master manifest and starts at 480p. Its first segment is 4 s × 1.2 Mbps = 4.8 Mb, about 600 KB, which arrives in about a second on a 5 Mbps link. The metadata call, two small manifest fetches and a few-KB init segment add about 100 ms from cache and edge. A player that last measured about 1 Mbps starts at 240p instead: 4 s × 0.4 Mbps = 1.6 Mb, about 1.6 seconds.
  • Measure every segment. The player divides each segment's size by its download time, and picks the highest rung whose bitrate is at most 70% of what it measured. At 18 Mbps it climbs to 1080p.
  • Watch the buffer. It keeps about 30 seconds of video buffered. In the tunnel the measured rate falls to 1.4 Mbps and the buffer starts draining, so the next segment comes from 360p (0.8 Mbps is under 70% of 1.4). Playback continues at a lower quality instead of stopping.
  • Climb back. After the tunnel, the measured rate returns to 20 Mbps, and the player steps back up to 1080p over the next few segments.

See it in the flythrough15 · Switch bitrate

Every rung's segments start on the same timestamps, so a switch is just fetching segment 31 from a different playlist. The player never asks a server to change anything; it makes every decision itself. That is what lets the CDN serve plain static files.

4. How do you serve 12.5 Tbps?

BadServe segments from the origin

Origin servers in one region read segments from S3 and send them to viewers. It is how the design works on day one, and S3 has no trouble storing the bytes. Sending them is the problem. Peak is 12.5 Tbps, which is about 1,250 servers with 10 Gbps cards, all running at line rate, in one region, and the cloud bills every byte that leaves it. Distance hurts too. A viewer in Sydney fetching from Oregon waits about 150 ms per round trip, and opening a TLS connection takes several, so the first frame is late. Every later segment crosses the same long path, which loses packets and slows each download, so the player drops to rungs his own link could carry.

See it in the flythrough12 · Bad: from origin

GoodA CDN in front of S3

Segments are static and never change once written, so a CDN can cache them for as long as it likes; playlists and manifests are small and cached for seconds. Edge servers near viewers serve the popular videos, and for the head of the catalogue that is the right answer. The long tail breaks it. Each of hundreds of edge locations has a small cache and misses on its own. A video watched 30 times a day across a continent rarely has two viewers at the same edge, so nearly every view misses. Even at a 95% edge hit rate, 5% of 2M segment GETs a second is 100,000 requests a second to S3, and S3 sends the same long-tail segment once for every edge that asks.

GreatCDN tiers, with the long tail in the middle

  • Edge. Hundreds of locations near viewers, with small caches, serve the popular segments. They hit about 95% of the time.
  • Mid-tier. A few regional caches sit between the edges and S3, with much larger disks. A miss at any edge in the region goes to the mid-tier, so 50 edges asking for the same long-tail segment cause one fetch from S3. The mid-tier holds the long tail and hits about 80% of what reaches it.
  • Arithmetic. 12.5 Tbps × 5% = 625 Gbps reaches the mid-tier; 625 Gbps × 20% = 125 Gbps reaches S3. About 1% of the bytes come from origin.
  • Warm the edges for big releases. When a channel with millions of subscribers publishes, push the first segments of the middle rungs to the edges before the notification goes out.
  • The first segments are the hottest. Many viewers leave in the first 30 seconds, so the opening segments of every video are fetched far more than its last ones. Caches that weigh by request count keep them naturally.

See it in the flythrough13 · Great: CDN tiers

What a senior candidate adds:

  • Cache keys without tokens. A private video's playlists and segments all need protecting, but a per-viewer token in the cache key makes every viewer miss. Give the viewer a signed cookie that covers the video's path, have the edge check it on every request, and leave it out of the key.
  • Storage for the long tail. Most videos are rarely watched, yet every one stores all five rungs. Some systems encode only the lower rungs for a new uploader and add 1080p when the video draws views.
  • Origin failure. S3 sits behind the mid-tier, so a short S3 problem is absorbed by the caches for popular videos. Long-tail videos fail first.

5. How do you count views?

500M views a day is about 5,800 a second overall. That is easy in aggregate. The problem is one video: a premiere can draw 50,000 views a second, all on the same row.

BadAdd 1 to the row on every view

UPDATE videos SET views = views + 1 WHERE id = 'v_8Kq2'

It is one line and it is exact, and spread over the average of 5,800 views a second across all videos it might keep up. The premiere breaks it: 50,000 views a second land on one row. Every update takes the same row lock, so they run one at a time, and one row manages a few thousand updates a second at best. The rest queue, hold connections and time out. Postgres also writes a new version of the row for every update, which fills the write-ahead log, lags the replicas and leaves vacuum millions of dead rows an hour. The queued updates hold the connection pool, so the hottest video slows every other write on the table.

See it in the flythrough17 · Bad: a row per view

GoodIncrement a counter in Redis, flush it later

INCR views:v_8Kq2 handles about 100,000 increments a second on one Redis shard, so the premiere's 50,000 fits, and a job copies the counts to Postgres every few seconds. The hot row is gone, which is why this is the usual next step. Two holes remain. Redis keeps the count in memory and replicates asynchronously, so a failed primary loses the increments its replica had not received, and a node with no replica loses everything since the last flush: at 50,000 a second, 5 seconds is 250,000 views. And INCR counts requests, not viewers. Nothing records who watched, so one viewer refreshing the page adds a thousand views, and there is no event log to recount from once you notice.

GreatView events into Kafka, counted in batches

  • Events. The player calls POST /videos/{id}/views after 30 seconds of watching, with its session id. The video service appends an event to Kafka, partitioned by video id, and answers 202.
  • Count in windows. A view counter, a Kafka consumer group, reads the events, drops a session's repeat views of the same video (it remembers each session and video pair for 24 hours), and sums views per video over 10-second windows.
  • One write per window. For each video with views in the window it writes once: views = views + 500000 for the premiere's 10 seconds at 50,000 a second. The table sees one write per active video every 10 seconds, however popular the video.
  • No lost counts. The counter commits its Kafka offset in the same Postgres transaction as the update, with the window's id, so a crashed counter replays from where it left off and never applies a window twice. A Flink job does the same with its own checkpoints and a sink that writes each window once.

See it in the flythrough18 · Great: count in batches

The count a viewer sees lags by about 10 seconds. That is the eventual consistency the requirements allow.

6. How do metadata and search scale?

The metadata is small: about 730 GB a year. What needs care is the read pattern.

  • Cache first. The video service reads video:v_8Kq2 from Redis, cache-aside, with a 60-second TTL, and deletes the key whenever the row's title or status changes. The view count is a separate key, views:v_8Kq2, which the view counter overwrites after every window, so it stays within 10 seconds. With a hit rate above 95%, Postgres sees a few hundred reads a second.
  • Read replicas take the misses and the listing queries. The primary takes about 12 inserts a second, the status changes and the view-count batches.
  • Hot keys. A viral video's key sits on one Redis shard. At 50,000 reads a second that shard copes, but the video service also keeps the top few thousand videos in memory for 5 seconds, so most of those reads never leave the server.
  • When to shard. Not yet. Partition the table by video id when it reaches several TB, which at this rate is years away. Say so, instead of sharding on day one.
  • Search, if asked. Do not search Postgres with LIKE. Feed changes to the videos table through change data capture (Debezium into Kafka) to an indexer that writes Elasticsearch: title, description and owner. The indexer skips changes that touch only the view count, and a separate hourly job copies counts into the index for ranking. A new video becomes searchable a few seconds after it is ready.

Final design

One upload. Jane's browser calls POST /videos, and the upload service writes her row as uploading and starts a multipart upload of 75 parts. The browser PUTs 16 MB parts straight to S3, four at a time, through presigned URLs. Her Wi-Fi drops at part 52; the browser asks which parts S3 holds and sends 52 to 75. On complete, S3 joins the parts, and its event goes to the queue. The orchestrator splits the 12 minutes into 180 chunks, workers run 900 transcode tasks in parallel, the packager writes the playlists and the master manifest, and the row turns ready.

See it in the flythrough09 · Every upload

One view. John's player calls GET /videos/v_8Kq2, and the video service answers from Redis with the manifest URL. The player fetches the master manifest from a nearby edge, starts at 480p, and plays within about a second. It climbs to 1080p, drops to 360p in a tunnel, and climbs back. Segments come from the edge, or from the regional mid-tier, and only rarely from S3. After 30 seconds, a view event goes to Kafka, and the count on the page rises within 10 seconds.

See it in the flythrough16 · Every view

See it in the flythrough20 · End to end

ComponentRoleScales by
Upload serviceCreates rows, starts, signs and completes multipart uploadsStateless servers
S3 originalsThe uploaded files, kept in a cold tier after processingThe provider
Queue and orchestratorStarts one DAG per video, tracks its tasks, retriesWorkflow engine
Transcode workersOne chunk at one rung per task~35,000 cores, scaled on queue depth
PackagerPlaylists per rung and the master manifestStateless workers
S3 segmentsCMAF segments and manifests, served as originThe provider
CDN edge and mid-tierServe segments; edge for popular, mid-tier for the long tailThe provider, 12.5 Tbps at peak
Video serviceMetadata API, view eventsStateless servers
RedisMetadata cacheA small cluster
PostgresVideo rows, status, view countsOne primary, read replicas
Kafka and view counterView events, summed per 10 sPartitions by video id

What is expected at each level

Junior. You keep video bytes in blob storage and metadata in a database, upload with a presigned URL, and serve videos through a CDN. With a nudge, you transcode into several resolutions.

Mid-level. You design the multipart upload with resume, a processing step that produces a bitrate ladder cut into segments with an HLS or DASH manifest, and adaptive playback from a CDN. You own one deep dive end to end, usually uploads or transcoding, with the arithmetic.

Senior and above. You lead with the numbers: 1.25 PB a day of storage and 12.5 Tbps of egress shape everything. You design the chunk-level DAG with idempotent tasks and retries, adaptive bitrate with the reasoning for each switch, CDN tiers for the long tail, and view counts in batches. You name the failure modes: a crashed worker, a duplicate S3 event, a corrupt original, a viral video's hot row and hot key. At the top of this level you also say what a first version could do without (one transcode job per video, one CDN tier, metadata in one Postgres with replicas), at what numbers each piece earns its place, and which trade-offs a team would raise: storing every rendition against transcoding the long tail on demand, and the CDN bill against start-up time.

Common mistakes

  • Video bytes through the API servers. 46 Gbps in and 12.5 Tbps out have no business on an API server. Presign uploads, and serve playback from a CDN.
  • Video bytes in the database. Store them in S3; store facts about them in Postgres.
  • One long upload request. A drop at 9 GB loses 9 GB. Use a multipart upload and resume it.
  • Transcoding a whole file in one job. Split it into chunks, and transcode them in parallel.
  • One resolution. Without a ladder and a manifest the player cannot adapt, and a phone in a tunnel stalls.
  • Treating the CDN as a single cache. The long tail misses at every edge. Add a mid-tier.
  • A row update per view. One popular video's row becomes the bottleneck of the table. Count in batches.
  • Sharding metadata on day one. 730 GB a year fits on one Postgres; cache it and add replicas.

Be ready for whichever one they pick

Practice each with an interviewer who grades every step, in the 14-day free trial

Walk into the system design round ready

Practice all 50 system design problems on a whiteboard, with graded feedback on every step, alongside 1,500+ real interview questions. A learning engine brings every problem back before you forget it. 50,000+ engineers have prepared with Firecode.

14-day free trial. Cancel anytime with one click.

Built by former engineers at

I have an account
50,000+engineers preparing with Firecode
1500+real interview questions from top tech companies
14languages, from Python to Rust
FAANG+offers landed at Google, Meta, Netflix, and more
Google Meta Amazon Apple Microsoft Netflix OpenAI Anthropic Stripe Nvidia Airbnb Uber Coinbase DoorDash Spotify Shopify Snowflake Cloudflare Bloomberg Dropbox