How YouTube Video Addresses Are Generated, And Why It Will Never Run Out Of Them

How YouTube Video Addresses Are Generated, And Why It Will Never Run Out Of Them

by Gary Oldwood on 15 August 2016 · 3314 views

5 large How YouTube Video Addresses Are Generated And Why It Will Never Run Out Of Them

Imagine what would happen if YouTube ran out of URLs; if every video uploaded brought the available addresses closer to zero, so that no more videos could be uploaded. Fortunately, this is practically not going to happen, because YouTube has made sure of that.

In this guide we will show you how YouTube addresses work.

How many videos are uploaded on YouTube daily?

YouTube is the second largest website in the world- and the universe, as far as we know- so it is likely that you have visited it at least a few hundred times.

In 2014, YouTube users were uploading videos with a total duration of 300 hours per minute. The same year, the average video duration was 4,4 minutes.

In other words, more than 4.000 videos were uploaded every minute, or nearly six million videos every 24 hours. Of course, these numbers have increased since then.

How YouTube links work

Each video uploaded to YouTube has a unique ID consisting of 11 characters. This ID appears after the watch?v= part in a YouTube link.

1 full How YouTube Video Addresses Are Generated And Why It Will Never Run Out Of Them

However, this ID doesn’t consist only of numbers- and the reason is because YouTube does not use the decimal number system for creating it.

These characters are not random letters and digits, but they represent a normal number, as real as 3, 100, or 1A.

Number systems

The number system we all know is the decimal, or base-10, which uses 10 digits to generate all numbers.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Once the first 10 digits are exhausted, we generate combinations of them: 11, 12, 13... etc.

But we saw that computers do not use the decimal numbering system, but the binary system (base-2) instead, which has only two digits:

0, 1

So, to represent the number 2 in the binary system, we have to combine the existing digits so that they form the number 10. Similarly, 3 is 11, 4 is 100, 5 is 101 etc.

Another common number system is the octal (base-8), which consists of digits from 0 to 7, so the next number after 7 is 10.

What all these number systems have in common is that they use only numbers. But what will happen if we wanted a number system beyond decimal? The solution is to begin using letters.

One example that is often used in computers is the hexadecimal system (base-16), which consists of 16 characters:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

In the hexadecimal system, then, we can count up to 15 using a single character.

2 large How YouTube Video Addresses Are Generated And Why It Will Never Run Out Of ThemConversion table between decimal, binary, octal, and hexadecimal systems (Image source)

It is easy to observe that, the greater the base of the numbering system, the smaller the number of characters is needed to express large numbers.

The number 4096 in the decimal system needs 4 characters. In the binary system it needs 12 characters (111111111111), while only 3 characters are required in the hexadecimal system (FFF).

YouTube’s number system

YouTube was created in February 2005, one year after Facebook (February 2004), and the first video was uploaded in April 2005.

So, while designing the service, the developers made sure that YouTube addresses practically cannot be exhausted. And the cornerstone in the design was the use of the Base-64 number system.

Similarly to other number systems, Base-64 consists of 64 characters: digits 0-9, the Latin alphabet with capital letters A-Z, the Latin alphabet with lowercase letters a-z, plus two extra symbols, + and /.

3 full How YouTube Video Addresses Are Generated And Why It Will Never Run Out Of ThemConversion equivalences between Base-64 values and ASCII characters (Image source)

Regarding YouTube links, the / character cannot be used in the IDs, since it is recognized as a separator in URL addresses. In this case, instead of the + and /, the characters - and _ were used.

Subsequently, when a YouTube video has the ID fJ9rUzIMcZQ, it means that it's representation in the decimal system is 1241591078350121131480.

What is the maximum number of YouTube IDs?

If YouTube addresses consisted of a single Base-64 character, there could be a maximum of 64 different IDs, from 0 up to _.

With 2 characters, there could be 64*64 combinations, or 64^2, which equals 4.096 possible IDs.

With 3 characters, the possible combinations are 64^3 = 262.144.

With 4 characters, the possible combinations are more than 16 million.

But every YouTube ID consists of 11 characters, which means that the possible combinations are 64^11 = 73,786,976,294,838,206,464.

In simple words, there are enough addresses so that if any one of the 7 billion inhabitants of our planet up uploaded a video every minute, it would take 20,000 years to use them all.

Technically, therefore, the available YouTube links are not infinite, and every video uploaded does reduce their number.

Practically, however, it’s possible that there will still be many IDs left even after humanity is long gone from the planet.

And even if in the year 100.000 there are still humans using the internet, and the available YouTube IDs are beginning to become extinct, the developers could always add an extra digit to them, making their total number 64 times bigger.

Why aren’t YouTube IDs generated in order?

YouTube never generated its video IDs in order, which is why the first YouTube video has the ID jNQXAC9IVRw instead of 00000000000.

The reasons for this are two. First, YouTube has dozens of servers for uploading videos from any place in the world. If video addresses were generated in order, there would be a problem in synchronization, since each server would have to know exactly what should the next YouTube address be.

4 full How YouTube Video Addresses Are Generated And Why It Will Never Run Out Of Them

But a slight delay in communication would result in two videos ending up with the same address.

With the current system however, YouTube generates a random number, and simply checks if is hasn’t been used in the past, which is much simpler, and minimizes the probability of making an error like that.

The second reason is that, if YouTube addresses were given in order, security issues would exist.

For example, unlisted videos (videos which can only be accessed if a user has their link) would be meaningless if the addresses were generated in order, since they would be accessible directly by brute-forcing the IDs in a specific range.

That’s it, now you know how YouTube creates the addresses for its videos, and you can keep uploading more of them without worrying about the service running out of IDs.

[Sources: StackOverflowWill YouTube Ever Run Out Of Video IDs?]

Comments (0)
Featured Articles