by troyk · 12y ago · 0 comments
Also, I tried the uuid extension once... It is not well supported, had to make a small change to a c header file to get it to compile on ubuntu, for dev on os x I think I gave up.
I've used UUID-as-pkey and had it work well.
UUID has no guaranteed properties you can rely on in high volumes.
The only desirable property it has is that it's an easy way out in tutorials.
The better solution is simply longer to explain (have a unique name for each server, an incremental generation number every time the server is restarted, and an incremental number on top of that for the runtime of a given generation - way Erlang does it).
"only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%."
http://en.wikipedia.org/wiki/Universally_unique_identifier#R...
Now, if you want to mark your product SKU with an UUID you have an outstanding chance it'll be unique amongst other UUID SKUs in the scope of every shop selling your SKUs.
But people have been captured by the idea UUID is truly "universally unique", so you can use it for everything, at any volume.
Not at all. Let's say that we're implementing a distributed Actor system (or a similar message passing architecture) at the scale of Google. We'll be using UUID to tag every message to guarantee its identity and various messaging properties (like deliver just once etc.), because UUID is unique. While actor systems can reach millions of messages per server per second, here we'll use a humble 100k messages per second.
- They have over 2 million servers (2,000,000)
- Each of which generates 100k messages per second.
You reach a point of 50% collision rate (for every new UUID) in 3 years:
log2 (2,000,000 * 100,000 * 3600 * 24 * 365 * 3)= ~64
2^64 is roughly the number of 128-bit UUIDs you need to reach that collision rate due to the Birthday paradox.Now you might say, I have a lot of variables pegged to worst case scenario. Sure I have. But this is about 50 damn percent chance of collision on every new UUID generated at that point.
Things will become bad long before 50% collision chance if you use UUID.
That's incorrect. If you go back to the birthday paradox, what you say would mean that, if you have 23 people in a room, and a 24th walks in, there is a 50% chance that that new person shares their birthday with one of those 23. That clearly is incorrect; that probability is at most 23/365 < 0.10.
Also, I don't see how your formula proves it. You will go through 64 of the 128 bits of key space in 3 years, but that means you only got through 2^-64 part of the key space, so each next UUID has a chance of about 2^-64 of a collision.
It's the sheer number of lottery draws with ever increasing probability of a loss that introduces the birthday paradox, not the last lottery.
I guess most of the messages created in such a system will be emphemeral...