Skip to main content

YouTube: Delivery Deep Dives

Editorial

How much of the traffic can caches take?

Views Are Concentrated

Two measurements, fifteen years apart, describe how YouTube's views spread over its videos:

  • 2007, from a crawl of YouTube's categories: "10% of the top popular videos account for nearly 80% of views, while the rest 90% of videos account for less than 20% of views."
  • 2022, from a random sample of all public videos: "The mean number of views of videos in our sample was 5,868.02, with a median of 35"; videos with 10,000 views or more were "only 3.67% of our sample … but they account for 93.61% of total views across the sample"; and "just the 16 most viewed videos in the sample (0.16%) together account for more views (50.52%) than the rest of the sample combined." Videos "with no views whatsoever accounted for 4.88%".

The 2022 numbers fit a lognormal distribution with the median and mean measured (σ = 3.2). That fit predicts 3.86% of videos at 10,000 views or more drawing 92.4% of views — close to the 3.67% and 93.61% measured — and overstates the very top (60% for the top 0.16% against 50.5%).

Views are concentrated: 0.16% of videos draw half of all views. The share of all views against the share of videos, most-viewed first, on a log scale. The curve is a lognormal fit to a 2022 random sample of YouTube; the sample's own points: the top 0.16% of videos drew 50.5% of views, and the top 3.67% (those with 10,000 views or more) drew 93.6%. A 2007 crawl of popular categories found the top 10% drawing about 80%. In the 2022 sample the median video had 35 views, the mean was 5,868, and 4.88% were never watched once. For caches: a small head of the catalogue serves most requests, and the tail is rarely seen.

What a Cache of Each Size Serves

From that distribution we computed what a cache holding a given share of all videos serves — with least-recently-used eviction (Che's approximation over 2 million videos, requests in proportion to views, sizes in proportion to the sample's durations), and for a cache that knew the future and kept exactly the most-viewed videos:

Cache holdsRequests served (LRU)Bytes served (LRU)Perfect knowledge
0.01% of videos15.3%12.6%29.9%
0.1%39.6%34.3%54.0%
1%71.7%69.9%80.5%
5%90.5%89.8%93.9%
10%95.5%95.1%97.2%
A cache of 1% of videos serves 72% of requests: least-recently-used caching over YouTube's measured popularity. The share of requests a least-recently-used cache serves, by its size as a share of all videos: 0.01% serves 15.3%, 0.1% serves 39.6%, 1% serves 71.7%, 5% serves 90.5% and 10% serves 95.5%; the share of bytes is a little lower. A cache that knew the future and held exactly the most-viewed videos would serve 29.9%, 54.0%, 80.5%, 93.9% and 97.2%. Google says its caches inside ISPs typically serve 70 to 90% of cacheable traffic — on this model, a cache of about 1 to 5% of the catalogue.

Google says of the caches it places inside ISPs: "Typically between 70-90% of cacheable traffic can be served from GGC. Cache hit rates will vary, based on the unique consumption patterns of end users on each operator's network." On the model, that is a cache holding roughly 1–5% of the catalogue. The model is static: real demand also moves in time — the 2007 study found that a video that did "not get enough requests during its first days" rarely got many later — which helps a least-recently-used cache, and tastes differ by country, which is why each ISP's cache fills from its own users' requests.

Tiers

A miss at one cache need not go back to the origin. In 2011 researchers measured YouTube's delivery from 471 machines around the world, plus 843 open DNS servers, and found "a 3-tier physical cache hierarchy": primary caches in 38 locations, some inside ISP networks, and "8 secondary and 5 tertiary cache locations in US and Europe and owned by Google only." Google describes its network today as "three distinct elements": data centers, edge points of presence "at over 100 interconnection facilities around the world", and edge nodes inside ISPs, where "Static content that's very popular with the local host's user base, including YouTube and Google Play, is temporarily cached".

In the model, eight edge caches of 0.1% of the catalogue in front of one regional cache of 1%:

TierShare of requests
Served by an edge cache39.6%
Served by the regional cache32.2%
Reaching the origin28.2%

The regional tier turns a 40% hit ratio into 72% without adding a byte to the edges, which stay small enough to fit inside ISPs.

Tiers: a regional cache turns 40% into 72%. Eight edge caches, each holding 0.1% of the videos near its viewers, sit behind one regional cache holding 1%, which sits in front of the origin, object storage. On YouTube's measured popularity the edge caches serve 39.6% of requests, the regional cache 32.2%, and 28.2% reach the origin: with the regional tier, 71.8% are served by a cache. YouTube, measured in 2011: primary caches in 38 locations, 8 secondary and 5 tertiary.

Pull, Not Push

The caches fill on demand: a miss is fetched from the next tier and kept. Copying "popular" videos to every edge in advance sounds faster but wastes the edges' space on videos popular somewhere else, and the head of the distribution fills a pull cache by itself. Filling ahead pays only for a known spike, such as a scheduled premiere.

Three details make pull caching work at this scale:

  • Cache segments, not files. Many views end part-way — "after watching some portion of it", in the words of the 23-million-view study — so a video's first segments are requested more than its last; a segment-level cache keeps only the parts people watch.
  • One copy per site. Inside a cache site, each video's segments map to one server by consistent hashing, so the site's servers act as one large cache, and adding a server moves only a slice of the keys.
  • Collapse misses. When a new video goes viral, many viewers miss on the same segment at once; the cache sends one request upstream and holds the rest until it returns.

How does the player choose each segment's quality?

The Player Picks Every Segment

Adaptive bitrate is a decision the player makes before each segment: which rung to ask for. It has two signals — the throughput its recent downloads achieved, and how many seconds of video its buffer holds — and the rules differ in which they trust:

RuleDecides byUsed in
Throughputthe highest rung under a safety share of the estimated throughputdash.js's ThroughputRule: a fast and a slow moving average of past downloads, the lower one, times 0.9
Bufferthe buffer level alone: lowest rung while the buffer is short, highest when it is long, a ramp betweenBBA, tested at Netflix (Huang et al., 2014); BOLA (Spiteri et al., 2016), dash.js's BolaRule
Hybridthroughput while the buffer fills, buffer once it is fulldash.js's default: "If both throughputRule and bolaRule are enabled dash.js dynamically switches between those two rules based on the current buffer level" — in its code, to BOLA at 12 s of buffer and back below 6 s
Predictive and learneda model of the next few segments (MPC, Yin et al., 2015), or a neural network trained by reinforcement learning (Pensieve, Mao et al., 2017)research

Netflix's test of the buffer approach found that it "allows us to reduce the rebuffer rate by 10–20% compared to Netflix's then-default ABR algorithm, while delivering a similar average video rate". YouTube has not published its own algorithm.

One more rule runs beside all of them in dash.js: a download that is on course to take more than 1.8 segment durations, while the buffer is short, is abandoned and fetched again at the rung the measured throughput affords.

Three Rules on Real 4G

We replayed the three rules on real throughput: the 40 logs of a 4G dataset recorded on foot, by bicycle, bus, tram, train and car around Ghent, Belgium (van der Hooft et al., 2016) — 5 hours in all — over the VP9 ladder we measured (0.15 to 11.06 Mb/s), with 4-second segments, a 30-second buffer, and dash.js's settings and abandon rule:

Over 40 sessionsThroughputBuffer (BBA-0)Hybrid (dash.js)
Stalls3 (14.8 s)03 (14.8 s)
Sessions with a stall101
Average bit rate10.18 Mb/s10.38 Mb/s10.58 Mb/s
Quality switches342225354
One train ride: the buffer rule never stalled. The rung each rule asked for, segment by segment, against the throughput a phone measured over 4G on a train near Ghent (the first 300 seconds; the network nearly vanished from second 164 to 214). The ladder is the measured VP9 ladder, 0.15 to 11.06 Mb/s, in 4-second segments. The throughput rule averaged 8.8 Mb/s and stalled three times, 14.8 seconds in all, after asking for 2160p just before the outage. The buffer rule (BBA-0) averaged 9.8 Mb/s with no stall. The hybrid, dash.js's default, averaged 10.2 Mb/s and stalled the same three times.

On these 4G sessions the rules mostly agree, and the 30-second buffer absorbs most dips: in 5 hours only one session stalled at all. The difference is one moment — on a train, the network nearly vanished from second 164 to 214. The throughput rule and the hybrid had just asked for 2160p segments at full throughput and were left downloading 44 megabits over almost nothing; the buffer rule had been lowering its rate as its buffer fell. With the abandon rule switched off, the buffer rule stalled too, once, for 21.2 seconds: dropping a hopeless download is part of what kept it smooth.

Three lessons carry over: keep a buffer of tens of seconds; never let one estimate of throughput commit the player to a segment it cannot finish; prefer staying on a rung to switching on every fluctuation. Which rule is best depends on the network and the ladder — which is why Netflix tested BBA on groups of real users before relying on it.

What happens before the first frame?

What Happens Before the First Frame

Startup is a chain of round trips: find a server (DNS), open a connection, fetch the manifest, fetch the first segment of video and of audio, decode. Each round trip takes as long as the network path to the server and back, so a cache near the viewer shortens every step. That is why the caches matter for startup as much as for bandwidth, and why the player starts with a modest quality: a small first segment arrives sooner.

How much startup matters is measured. Across 23 million views, 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", and they are "less tolerant to startup delay for a short video such as a news clip than a long video such as an hour-long TV episode".

QUIC

YouTube's video travels over QUIC, the UDP-based transport Google built, on which HTTP/3 runs. It replaces the separate TCP and TLS handshakes with one and lets a returning client send its request in the first packet. Google reported in 2017 that QUIC "reduces rebuffer rates of YouTube playbacks by 18.0% for desktop users and 15.3% for mobile users". Part of the gain is that a lost packet delays only the stream it belongs to, not every request on the connection.

How does the metadata scale?

YouTube's Own Path

Vitess, the MySQL sharding system, began at YouTube: "Vitess was created in 2010 to solve the MySQL scalability challenges that the team at YouTube faced." The steps it records are the usual ones. YouTube first added a replica for reads, then more replicas; "Eventually, write traffic became too high for the primary database to handle, requiring YouTube to shard data". At first the application itself picked the shard for every query; Vitess moved that routing into a proxy, so the application talks to one logical database.

Sharding the Metadata

The watch page reads a video by its id, so video_id is the shard key: ids are random, so videos spread evenly, and a popular video is one row read many times — work for a cache, not for the database.

A channel's list of videos is a different query, by channel. Sharded by video, it would have to ask every shard. So the list lives in its own table, channel_videos, sharded by channel_id: one shard answers "the latest videos of this channel". Across shards the database no longer enforces the references between the two tables; the upload service writes the video row first and the channel row second, and a periodic check removes the rare orphan left by a crash in between.

The read load is caching work. A watch page needs a few rows, and popular videos are read millions of times a day, so the metadata servers keep watch-page data in a cache with a short lifetime and invalidate it when the creator edits the video. Counts are not in that path at all: they come from video_counts, which the counting job rewrites (next section).

How are views counted?

What Counts as a View

YouTube does not show every play as a view at once: "We want to make sure that your metrics are high quality and come from actual humans and not computer programs. It takes our systems some time to figure out which views, likes, dislikes, and subscriptions are legitimate." What a view is changes too: "Beginning August 24, 2026, views are counted the moment a video starts to play across all formats, including Shorts, long-form videos (VOD), and live streams." The count is therefore an output of a validating pipeline, never a field that each play increments.

One Counter, Three Ways

The load is large: Shorts alone average over 200 billion views a day, 2.3 million a second, and a video watched 100 million times in its first day takes 1,157 views a second on average. We measured one video's counter three ways, on PostgreSQL 17 with every commit flushed to disk and on Redis 8:

ApproachMeasuredWhat goes wrong
UPDATE video_stats SET views = views + 1, 16 connections250 a second; 58,193 with commits not flushedevery increment waits for the row's lock and a flush; unflushed, a crash loses acknowledged views
Redis INCR, flushed to PostgreSQL every second217,628 a second (2.6 million pipelined)killing Redis 2.5 s into a run lost 150,600 of 784,800 acknowledged views, 19%
Each view a row with its own view_id, 1,000 per transaction33,972 a second from one writer, every commit flushednothing: a batch sent twice was counted once
Counting views: an event log, not a hot row. One video's counter three ways, measured on PostgreSQL 17 and Redis 8. Updating one row: 250 increments a second with every commit flushed — one hot row caps it. Redis INCR: 217,628 a second, but a crash lost 19% of the views it had acknowledged. Views as events: 33,972 rows a second from one durable writer, and a batch sent twice counted once. The design: players send each view with its view_id to a view log partitioned by video; a counting job validates the events, drops repeats and writes video_counts every few seconds. Shorts alone average over 200 billion views a day, 2.3 million a second; partitions of the log add writers, and no row is ever hot.

The Counting Pipeline

  • The player sends events. Each play is a POST /v1/views with a view_id the player chose, so a retry repeats the id instead of adding a view.
  • A log takes them. The events go to a partitioned log, partitioned by video so one video's events are counted in one place; more writers mean more partitions, never contention on one row.
  • A job counts them. The counting job reads the log, drops events that fail validation or repeat a view_id, adds up each video's views for the interval, and writes video_counts with counted_to — the point in the log up to which the count is complete. The watch page reads that row, through the cache.
  • Counts are recomputable. Because the log keeps the events, a bug or a change in what counts as a view is fixed by counting again, which is what "constantly confirming and adjusting engagement events" requires.

If a single video ever outgrew one partition, its events could be spread by view_id and summed in a second step; repeats would still be caught, since a repeated event carries the same view_id.