tags:

views:

244

answers:

5

I have seen the GUID Collisons discussions but just wanted your thoughts on whether there could be a GUID collision if both clients accessed the same web page that generates the GUID at exactly the same time (- probably down to the micro-second) ?

+8  A: 

It's theoretically possible, but highly unlikely.

Kon
It is so unlikely to occur that you are far, far better off spending your time elsewhere. Your server is more likely to catch on fire than generate the same GUID twice.
Michael Haren
Yeah, 'highly unlikely' doesn't really do it justice, because in addition to the random element there's a sequential 'uniquifier' element. So not only would two users have to roll the same random number, it would have to happen to that number so many times that the uniquifier overflows.
Joel Coehoorn
+2  A: 

No. If that happens rush out and buy a lottery ticket!

Mitch Wheat
+1  A: 

From Wikipedia, the free encyclopedia

A Globally Unique Identifier or GUID (pronounced /ˈguːɪd/ or /ˈgwɪd/) is a special type of identifier used in software applications in order to provide a reference number which is unique in any context (hence, "Globally"), for example, in defining the internal reference for a type of access point in a software application, or for creating unique keys in a database. While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is very small. For example, consider the observable universe, which contains about 5×1022 stars; every star could then have 6.8×1015 universally unique GUIDs.

nmiranda
I call dibs on 411f4936-afb4-4a5b-a168-acfb6d750e03!
Will
+3  A: 

On a single server, no, it isn't possible. Version 4 Guids are made up (amongst other things) of a pseudo-random 54-bit value, and as I understand those, they cycle through all values before repeating.

If creating on more than one server, then it is possible to have a guid clash, although that is highly highly unlikely.

Refer to RFC 4122, specifically section 4.1.5. Modern Windows uses v4 UUIDs, I believe.

stusmith
+1  A: 

If you generate lots and lots of GUIDs, then likelihood of collision is getting quite high due to Birthday paradox. Theoretically GUID collision should be highly unlikely (naïve intuition) but practically it happens from time to time.

Sure, it's waste of time to handle these collisions programatically but you should still write your code in a way that if it happens, then your code should fail loudly, not quietly and undetected.

lubos hasko