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?
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?
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.
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.
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:
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.
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.
© 2022 - 2024 — McMap. All rights reserved.