Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the chances of getting the same GUID in 1 billion iterations?

Tags:

.net

guid

I am working on a project where I need to generate approximately 1 billion GUIDs.

I know GUIDs are not guaranteed to be unique but are unique almost all of the time.

If I generated a billion GUIDs, what is the probability that there will be a match?

like image 273
Diskdrive Avatar asked Jun 29 '10 06:06

Diskdrive


People also ask

How likely is it to generate the same GUID?

Likelihood of Collision Assuming a perfect source of entropy on each device generating random GUIDs, there is a 50% chance of collision after 2.7e18 random GUIDs have been generated. That's more than 2.7 million million million.

Will a GUID ever repeat?

Technically they are 128-bit unique reference numbers used in computing which are highly unlikely to repeat when generated despite there being no central GUID authority to ensure uniqueness.

What is the probability of two GUIDs being the same?

GUID generation algorithm 4 fills the GUID with 122 random bits. The odds of two GUIDs colliding are therefore one in 2¹²², which is a phenomenally small number.

How much of a GUID is unique?

The GUID generation algorithm relies on the fact that it has all 16 bytes to use to establish uniqueness, and if you throw away half of it, you lose the uniqueness. There are multiple GUID generation algorithms, but I'll pick one of them for concreteness, specifically the version described in this Internet draft.


2 Answers

http://blogs.msdn.com/b/oldnewthing/archive/2008/06/27/8659071.aspx

The .NET GUID consists of

  • 60 bits of timestamp,
  • 48 bits of computer identifier,
  • 14 bits of uniquifier, and
  • six bits are fixed

So the UUID probability quoted by Oscar does not work here. But if you create all your 1 billion GUIDs from one computer, there is no chance to get a duplicate (except you are playing with the clock ;-)

like image 85
Hinek Avatar answered Sep 21 '22 18:09

Hinek


If you are creating the GUIds from the same machine and using the same algorithm then you will not get a collision.

like image 32
Robin Day Avatar answered Sep 18 '22 18:09

Robin Day