Recess
Sign in
← Back to feed
You're reading as a guest. Sign in to save posts, see what's new, and tune your feed.
Sign in
TECHNOLOGY · BITE · 2 MIN · BEGINNER

Gangnam Style Broke YouTube's View Counter

YouTube's view counter stored views as a 32-bit integer — Gangnam Style was the first video to expose the limit.

A 32-bit signed integer can count up to 2,147,483,647 — that's 2 to the power of 31, minus one. For most of the web's history, nobody designed infrastructure expecting a single piece of content to need a bigger counter than that.

Psy's "Gangnam Style" changed the calculation. Released in July 2012, it became the first YouTube video to reach one billion views, then two billion. By late 2014 it was approaching the 32-bit ceiling. YouTube's engineers noticed before the counter actually wrapped — an integer overflow would have caused the view count to flip negative, which would have been visible to every user visiting the page.

On December 1, 2014, YouTube published a Google+ post acknowledging they had quietly upgraded the view counter to a 64-bit integer. The maximum value for a 64-bit signed integer is 9,223,372,036,854,775,807 — roughly 9.2 quintillion. YouTube noted, with some dry humor, that it would take quite a while to fill that.

At the time of the upgrade, Gangnam Style had approximately 2.147 billion views. It ended 2014 with about 2.15 billion — just past the old limit. The video remained the most-viewed on YouTube until 2017, when it was surpassed by "See You Again" by Wiz Khalifa. The overflow never happened; the fix arrived in time. It remains a clean example of a class of bugs — integer size assumptions baked into infrastructure by engineers who never expected certain scale — that has bitten everyone from YouTube to early Unix systems.

#software-bugs#integer-overflow#youtube#scale
Sources
YouTube / Google+ (archived)Wikipedia