Is there any possibility that GUID will all be used up?
Asked Answered
P

3

14

Given that each GUID is represented by 16 bytes. So at best there are 2^128 possibilities = 3.4028237e+38 possible GUIDs.

Will it be possible that it will all be used up?

Piefer answered 16/4, 2015 at 17:41 Comment(5)
Absolutely. Even if only one GUID is generated per second, we'll run out in a scant 9 quintillion years.That's well before the heat death of the Universe.Mckinzie
The question is valid but the more important question is: Do I need to protect myself against accidental duplicates? To which is answer is 100% no.Monti
@Monti Assuming GUIDs are generated completely randomly.Orthographize
just as people thought IPv4 was enough, now we need IPv6. haha just wondering. may be some radical breakthrough technology may change the way we track data? e.g. quantum computing? IoT? quantified self? And what if in 10 years time we live in a world where billions of data points (each with a guid) are generated per person per second. :PPiefer
and may be somehow machine:human ratio become unbelivably enormous.Piefer
C
6

No. Even if you assume extremely high usage of GUIDs in some area, and extremely long time scales, the key point about GUIDs is their uniqueness. As soon as you start to get repetitions with any probability that is of practical relevance, people will stop using GUIDs, and therefore won't use up any more of them. Sure, they might use some numbers which look like GUIDs in some areas, where sufficiently low usage can still help ensure local uniqueness, but those would only be LUIDs, and with a bit of luck people will also call them this way.

Cockneyfy answered 16/4, 2015 at 17:52 Comment(3)
was thinking that if someday 7 billion people each have 10 devices (wearable + computers) each generating 100 data points a second. It will still take 1.54e+18 years to consume all. May be I should rephrase the question to will it be possible that we have 1.54e+16 devices that generate multiple guids per second, and eventually consumed all guids..Piefer
well i guess we can then use 32 bytes to store guids then... hahaPiefer
@ChrisYeung: I guess the classical answer to huge numbers is postulating exponential growth. Humanity colonizing space, or creating GUID-using machines which do so, and have either multiply at an exponential rate. But the details of that are in the domain of science fiction, not Stack Overflow.Cockneyfy
B
15

To show you how big 2^128 GUIDs is:

1 GUID = 16 bytes.

Therefore 2^128 GUIDS would each need 16 bytes of storage, that is:

2^4 * 2^128 = 2^132 bytes

This works out to be 5,444,517,870,735,015,415,413,993,718,908,291,383,296 bytes; that's a number with 40 digits, 5.445 x 10^39, number of bytes.

There is no unit of storage big enough to quantify this number– the largest standardized unit of data is the "yottabyte", and if we use it, we still end up with a 16 digit value, or 5.445 quadrillion yottabytes (5.445 x 10^15).

So, first you would need to worry about being able to store that many GUIDs, before you could even consider running out of them.

Basically: it is functionally impossible for you to run out.


Collisions

Just because I've heard people worry about collision so many times, I will expand my answer to include an analysis of the possibilities of collisions.

There's a caveat to note here– (the majority of) randomly-generated UUIDs that are RCC-spec compliant actually have 122 bits of randomness instead of 128, because 6 bits are reserved to denote the version and variant of the UUID being generated. This reduces the amount of generatable UUIDs, and increases the potential for collisions, but it doesn't matter very much in practice because there are still so many possible UUIDs (but it does alter the collision math slightly).

According to the birthday paradox (when applied to hash functions), the expected number of hashes you would need to generate until you get a collision can be roughly approximated as 2^(n/2), where n is the total random bits.

Thus, for our UUIDs with 122 random bits:

2^(122 / 2) = 2^61

This means that, by the time you generate 2^61 UUIDs, there is a ~50% chance that you will get a collision with each UUID generation. As a an expressed value this is roughly 2.3 quintillion:

2,305,843,009,213,693,952 UUIDs

This is roughly equivalent to generating 1 billion UUIDs per second for 73 years:

            1,000,000,000     UUIDs/second
                       60     seconds/minute
                       60     minutes/hour
                       24     hours/day
                      365.25  days/year
*                      73     years
------------------------------------------
2,303,704,800,000,000,000     Total UUIDs

(This is also a lot of storage– 2.304 Exabytes, or 2.3 million Terabytes)

Also note that this is all assuming the UUIDs are generated with a good algorithm for Randomness and a good source of Entropy (i.e. all possible UUIDs are equally likely to be generated at any given time).

All in all, UUIDs/ GUIDs are designed specifically to minimize the chance of collision, and it's almost certainly not something you need to worry about in practice. It is far, far more likely that there's an error in an algorithm or code somewhere to cause collisions than it is to generate a collision "naturally".

Related reading:

Brotherson answered 16/4, 2015 at 18:0 Comment(0)
C
6

No. Even if you assume extremely high usage of GUIDs in some area, and extremely long time scales, the key point about GUIDs is their uniqueness. As soon as you start to get repetitions with any probability that is of practical relevance, people will stop using GUIDs, and therefore won't use up any more of them. Sure, they might use some numbers which look like GUIDs in some areas, where sufficiently low usage can still help ensure local uniqueness, but those would only be LUIDs, and with a bit of luck people will also call them this way.

Cockneyfy answered 16/4, 2015 at 17:52 Comment(3)
was thinking that if someday 7 billion people each have 10 devices (wearable + computers) each generating 100 data points a second. It will still take 1.54e+18 years to consume all. May be I should rephrase the question to will it be possible that we have 1.54e+16 devices that generate multiple guids per second, and eventually consumed all guids..Piefer
well i guess we can then use 32 bytes to store guids then... hahaPiefer
@ChrisYeung: I guess the classical answer to huge numbers is postulating exponential growth. Humanity colonizing space, or creating GUID-using machines which do so, and have either multiply at an exponential rate. But the details of that are in the domain of science fiction, not Stack Overflow.Cockneyfy
L
-3

I would only add that most probably we wouldn't want to arrive to a 1% of having a repeated Guid. Nonetheless for that you would need to have covered 2^121 (2658455991569831745807614120560689152) combinations, in order to have a 0.78125% chance of having a repeated Guid.

Lindley answered 5/1, 2022 at 11:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.