DEV Community

Cover image for Youtube Overflow
Alex P
Alex P

Posted on • Originally published at open.substack.com

Youtube Overflow

I have written about a case when some outdated software components were used for more modern conditions, and it led to the Ariane 5 crash. But this time I wrote about a simpler case

So, at the end of 2014, the video Gangnam Style reached the most views ever in the whole of YouTube history.
And suddenly the counter of views stopped on the number 2 147 483 647 (2^31)
The counter is literally broken

Initially, YouTube was developed via the Python language, which handles large numbers very well.
But the database MySQL isn't!
And if a number is defined like a signed int the value 2 147 483 647 is the maximum

Of course, YouTube's developers implemented a fix quickly, and now the max value for counters takes 64 bits. This number is so big, so it takes more than 4 billion years for mankind to reach the limit... I would like to live so long đź––

A little demo of how it doesn't work for MySQL https://www.db-fiddle.com/f/uuVvjyPmCqyD3Mk38SCQhF/1

And what happens on the Python https://python-fiddle.com/?checkpoint=1771142861

It was so cool that Youtube's developers added the Easter egg on the video page that broke their counter
Unfortunately they have removed it, but some good persons kept the video for history

Top comments (0)