3 ms·
> No you cannot, unless you're running a single threaded server process on a single machine. What you can do is _gamble_ that you probably won't have a collisio
by bearmcbearsly 8y ago
> No you cannot, unless you're running a single threaded server process on a single machine. What you can do is _gamble_ that you probably won't have a collision
This seems like a pointless distinction.
If I did the math right, you can generate 1,000,000 ULIDs per second (1000 per millisecond) for around 50 million years before you can expect to hit your first collision.
I don't know about you, but I'm pretty sure any system I build won't be running 50 million years from now. Not to mention that the timestamp portion of the ULID will overflow in a mere 9000 years.
- deleted 8y ago[deleted]
- yen223 8y agoDoes your math rely on perfect entropy on machines you don't control?
- ngrilly 8y agoYes. I did the math and got the same result, relying on a perfect entropy hypothesis.
- InGodsName 8y agoDid you account for long tail events?
- dtech 8y agoThe point was that this was not an advantage of ULID over UUID. You need 2.7 * 10^18 v4 UUIDs for a 50% collision chance.
- espadrine 8y agoI agree that collision is not an issue. On the other hand, your consistency assumptions may be broken if you rely on the sort order for causality relationship. You can have ULID1 < ULID2 and yet the event associated with ULID1 may be caused by the ULID2 event.
- ngrilly 8y agoI did the math too after reading your comment and got the same result: on average, with 1,000,000 ULIDs per second, I'll wait 50 million years before hitting the first collision. Here is the Python code I used: https://gist.github.com/ngrilly/565bd27f4ad63244f72578844bca5f17 https://gist.github.com/ngrilly/565bd27f4ad63244f72578844bca... But I'm curious to know how you computed this?