SCRU128: Sortable, Clock and Random number-based Unique identifier
github.com
github.com
If you have an overflow condition you want to encounter (i.e. test) it often.
32bit miliseconds + 96 bit of real entropy is brute force resistant, and has a ~50 day overflow period.
That's plenty for eyeball statistics and to make DB indices happy.
Any more sophisticated analytics will require larger precision and timezoning anyways, so don't cram it into the ID and give it it's own field.
Also don't muck with entropy. All these smart counter schemes are potential attack vectors and have a much higher collision probability.
You're more likely to get a collision due to but flips in such a counting scheme than from two randomly colliding full entropy bitstrings.
You can do both, use a low precision timestamp with overflows in the ID to keep the index happy, and add a proper timestamp field for analytics.
The 32 + 96 split is what postgres uses for example. I'd say that's a pretty good endorsement.
Since I could drop one char from Base 36, and still store 128 bits, I decided to drop the "l", to reduce ambiguity with "1". And since I used lower case letters, "o" and "0" look quite different.
128 bits is often an overkill when dealing with single-digit rps.
This is perplexing and I'd like to see the assumptions spelled out about how many such generators will run at the same time. If there are 1000s of generators, that almost guarantees occasional free collisions in the per-second field. If two such colliding generators each make a million ID's in the same millisecond, that basically guarantees full 72-bit collisions. Plus the monotonically increasing counter field can be a technical challenge in its own right. If you can generate those reliably and want to make the uuid's opaque to attackers, you might as well just encrypt a 64-bit monotonic counter with a 128 bit block cipher, with your db able to decrypt the counter for indexing purposes.
https://www.ietf.org/archive/id/draft-peabody-dispatch-new-u...