WEBVTT
Kind: captions
Language: en

1
00:00:00.080 --> 00:00:03.120
Every YouTube video has a unique ID.

2
00:00:03.120 --> 00:00:05.770
It's up in the URL: a string of eleven characters

3
00:00:05.770 --> 00:00:08.820
that uniquely identifies which video you want.

4
00:00:08.820 --> 00:00:12.580
Now, YouTube has millions and millions of
videos.

5
00:00:12.580 --> 00:00:16.460
The last stats that they released said they
have

6
00:00:16.460 --> 00:00:20.380
400 hours of video being uploaded every minute.

7
00:00:20.380 --> 00:00:23.369
So: are they ever going to run out of those
IDs?

8
00:00:23.369 --> 00:00:27.240
Well, to find out, let's talk about counting
systems.

9
00:00:27.240 --> 00:00:29.509
People count in Base 10. 0 to 9.

10
00:00:29.509 --> 00:00:31.949
That'll be, hopefully, familiar to you.

11
00:00:31.949 --> 00:00:34.060
Computers count in base 2, in binary,

12
00:00:34.060 --> 00:00:36.200
but that's difficult for humans to read,

13
00:00:36.200 --> 00:00:38.900
it gets too long to write really, really quickly,

14
00:00:38.900 --> 00:00:43.650
so often computers will display it in base
16, hexadecimal.

15
00:00:43.650 --> 00:00:46.340
You have 0 to 9, and then A to F,

16
00:00:46.340 --> 00:00:49.040
and then you start adding to the next column.

17
00:00:49.040 --> 00:00:50.660
Humans can't understand that easily,

18
00:00:50.660 --> 00:00:53.400
but it's efficient if we have to type it in
somewhere,

19
00:00:53.400 --> 00:00:59.100
and 16 - 2 to the power of 4 - is also easy
for computers to deal with.

20
00:00:59.100 --> 00:01:00.790
So how about Base 64?

21
00:01:00.790 --> 00:01:05.360
That'd be a ridiculous counting system, right?
Except.

22
00:01:05.360 --> 00:01:08.000
64 is another one of those easy numbers for
computers,

23
00:01:08.000 --> 00:01:10.370
it is 2 to the power of 6.

24
00:01:10.370 --> 00:01:12.750
And humans can get to 64 very easily:

25
00:01:12.750 --> 00:01:15.670
0 to 9, then capital letters A to Z,

26
00:01:15.670 --> 00:01:18.770
then small letters a to z, and two other characters.

27
00:01:18.770 --> 00:01:20.850
Most Base 64 uses slash and plus,

28
00:01:20.850 --> 00:01:22.810
but they don't work so well in URLs,

29
00:01:22.810 --> 00:01:25.830
so YouTube uses hyphen and underscore.

30
00:01:25.830 --> 00:01:28.090
That YouTube URL, that unique ID,

31
00:01:28.090 --> 00:01:32.270
is really just a random number in base 64.

32
00:01:32.270 --> 00:01:34.370
They could have have picked base 10 or base
16,

33
00:01:34.370 --> 00:01:36.200
but they didn't: they went with 64,

34
00:01:36.200 --> 00:01:40.520
because it will let you cram a huge number
into a small space

35
00:01:40.520 --> 00:01:43.090
and still make it vaguely human readable.

36
00:01:43.090 --> 00:01:45.840
Author and programmer Sam Hughes, by the way,

37
00:01:45.840 --> 00:01:51.210
pushed this to the limit, and invented Base
65,536,

38
00:01:51.210 --> 00:01:54.740
which includes basically every character from
every language.

39
00:01:54.740 --> 00:01:56.960
It is ridiculous and unnecessary,

40
00:01:56.960 --> 00:01:59.570
but when has that ever stopped programmers?

41
00:01:59.570 --> 00:02:04.659
So why didn't YouTube just start counting
at 1 and work up?

42
00:02:04.659 --> 00:02:07.780
Well, first, they would have to synchronise
their counting

43
00:02:07.780 --> 00:02:11.370
between all the servers handling the video
uploads,

44
00:02:11.370 --> 00:02:14.400
or they'd have to assign each server a block
of numbers.

45
00:02:14.400 --> 00:02:16.680
Either way, there's a lot of tracking to do,

46
00:02:16.680 --> 00:02:18.740
a lot of making sure that it's never duplicated.

47
00:02:18.740 --> 00:02:21.690
Instead, they just generate a random number
for each video,

48
00:02:21.690 --> 00:02:24.590
see if it's already taken, and if not, use
it.

49
00:02:24.590 --> 00:02:28.090
And secondly, it is a really, really bad idea

50
00:02:28.090 --> 00:02:32.390
to just count 1, 2, 3 and so on in URLs.

51
00:02:32.390 --> 00:02:35.550
Incremental counters, as they're called, can
be a big security flaw:

52
00:02:35.550 --> 00:02:39.510
if you see video 283 up there, then you might
wonder:

53
00:02:39.510 --> 00:02:42.260
what's video 284? Or video 282?

54
00:02:42.260 --> 00:02:43.990
It's easy to enumerate, as it's called,

55
00:02:43.990 --> 00:02:46.520
to run through the entire list.

56
00:02:46.520 --> 00:02:49.420
YouTube Unlisted videos, the ones that don't
appear publicly

57
00:02:49.420 --> 00:02:52.450
but that you can send the link to people,
those wouldn't work.

58
00:02:52.450 --> 00:02:57.970
And by the way? Lots of badly designed sites
do use incremental counters.

59
00:02:57.970 --> 00:03:00.550
And it is a terrible idea.

60
00:03:00.550 --> 00:03:03.569
It might tell your competitors exactly how
many customers you have,

61
00:03:03.569 --> 00:03:04.880
'cos they can just count them.

62
00:03:04.880 --> 00:03:07.750
It might let people download all your records
easily,

63
00:03:07.750 --> 00:03:08.810
'cos they can just run through them.

64
00:03:08.810 --> 00:03:12.920
And in one site that someone in Florida emailed
me about this week,

65
00:03:12.920 --> 00:03:16.520
it lets you look at other people's personal
details.

66
00:03:16.520 --> 00:03:21.380
Don't use incremental counters if you're building
a web site. Use a random number.

67
00:03:21.380 --> 00:03:22.930
Which brings me to the question:

68
00:03:22.930 --> 00:03:26.260
just how big are the numbers that YouTube
uses?

69
00:03:26.260 --> 00:03:28.310
Well, let's work it out.

70
00:03:28.310 --> 00:03:32.310
One character of base 64 lets you have 64
ID numbers.

71
00:03:32.310 --> 00:03:37.569
Two characters? That's 64 by 64, or 4,096.

72
00:03:37.569 --> 00:03:42.610
Three characters? 64 times 64 times 64 -- or
64 to the power of 3.

73
00:03:42.610 --> 00:03:45.560
That is already more than a quarter of a million.

74
00:03:45.560 --> 00:03:50.590
And if we go to four? Well, now we're above
16 million.

75
00:03:50.590 --> 00:03:53.980
If you use Base 64, then you can assign an
ID number

76
00:03:53.980 --> 00:03:57.410
to everyone who lives in London down there
twice over,

77
00:03:57.410 --> 00:04:00.489
and you'll only need four characters.

78
00:04:00.489 --> 00:04:02.950
This gets big fast. We can keep on doing this,

79
00:04:02.950 --> 00:04:06.660
and by seven characters we're already at four
quadrillion.

80
00:04:06.660 --> 00:04:10.300
Now, I assume that YouTube checks through
a dictionary,

81
00:04:10.300 --> 00:04:13.660
and doesn't allow any actual words to appear
up there --

82
00:04:13.660 --> 00:04:15.250
particularly anything rude.

83
00:04:15.250 --> 00:04:18.669
But that is going to be a tiny minority of
the URLs,

84
00:04:18.669 --> 00:04:22.069
so for our purposes, we can pretty much just
ignore that.

85
00:04:22.069 --> 00:04:27.169
At YouTube's 11 characters, we are at 73 quintillion
786 quadrillion

86
00:04:27.169 --> 00:04:30.589
976 trillion 294 billion 838 million

87
00:04:30.589 --> 00:04:32.479
206 thousand and 464 videos.

88
00:04:32.479 --> 00:04:35.669
That's enough for every single human on planet
Earth

89
00:04:35.669 --> 00:04:41.629
to upload a video every minute for around
18,000 years.

90
00:04:41.629 --> 00:04:42.599
YouTube planned ahead.

91
00:04:42.599 --> 00:04:45.889
Can they run out of URLs? Technically, yes.

92
00:04:45.889 --> 00:04:49.969
Practically? No. And if they did?

93
00:04:49.969 --> 00:04:52.559
They could just add one more character.

94
00:04:53.640 --> 00:04:56.180
[Translating these subtitles? Add your name here!]

95
00:04:57.320 --> 00:05:02.960
Ha! One take! One take! Yes!

