~learn.
0:00 / 1:37
Side quest 19 · YouTube

Why YouTube can't just do views + 1

transcript

The obvious way to count a view? Add one to the video's row. On a big premiere, it melts.

One row per video, plus one per view. Fine under 1,000 a second. A video taking off at 9 PM does 3,000. Already too hot. A music video premieres. 50,000 real view starts a second, on one video. Plus a bot farm adding 5,000, from 200 addresses. And players retry, so views double-count.

So a view isn't an increment. It's an event, with a fresh ID per playback. Seen that view ID already? It's a player retry. Drop it. Once a second, each worker sends one small total per video. Above 1,000 views a second, that video's counter splits into 64 shards.

But here's the catch. How do you partition that stream? By video ID? Then one viral video lands on one partition. You haven't fixed the hot row. You've just moved it. By view ID, every worker takes a share of the viral video.

And the bots? A filter scores views: address, device, tabs, progress. The creator sees a provisional count, live in a second or two. The public count only grows by views the filter cleared. It may freeze, or change.

A view count isn't a number. It's a pipeline. Dedupe, filter, shard, verify. Eventually right, not instantly right.

Full breakdown in the lecture.