Saiful OCG MY
Saiful OCG MY

Reputation: 31

How ramsey/uuid be unique world wide?

i used ramsey/uuid in my laravel project. i want to get unique id for non registered members to track their activities. but uuid1 and uuid4 generates random id for same member with same pc. on the other side uuid3 and uuid5 generate same id of my different testing pc. have any idea can make the unique identifier machine based for each end user?

Upvotes: 3

Views: 1128

Answers (2)

rap-2-h
rap-2-h

Reputation: 32048

UUID v4 is ~unique worldwide (with negligible risk). Quoting this answer:

The annual risk of a given person being hit by a meteorite is estimated to be one chance in 17 billion, which means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate. In other words, only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%.

You could use random UUID v4 for your need.

Upvotes: 2

online Thomas
online Thomas

Reputation: 9401

UUID is designed for that. There are so much possibilities that you never* get a duplicate, even when using multiple machines.

Thus, for there to be a one in a billion chance of duplication, 103 trillion version 4 UUIDs must be generated.

https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions*

Upvotes: 2

Related Questions