You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The automatic scaling of id length based on generation rate is pretty cool, but it has some drawbacks.
As one user pointed out, if ids are generated rapidly in clusters, it can create ids that are too long.
If run for a long time at a low rate, it can create ids that are too short! Generating 1 id per second, the ids stay short (9 characters = 54 bits). After only a year (30 million ids) the odds of a collision increase to 2.5%. (And if 4 different servers each generate 1 id per second, it'll only take 3 months to get the same odds of a collision!)
When I know my own use case and how important it is to me to avoid a collision, I'd like to be able to skip the timing code and just specify the length myself.
It'd be nice if I could call generate(12), and get output of the specified length. (Or, generateFixed could be its own function, separating out the timing code completely for those who don't want it to be part of their project.)
The text was updated successfully, but these errors were encountered:
There's no chance of collision if there's a single server or you set a different worker id on each. If you have more than 16 servers, you can device a way to give each server a letter and append it to IDs and then the amount of servers you can have in the cluster safely skyrockets.
As for length, I showed on another issue that they don't get that long at high-scale. As I said there, you need to generate more than 4 IDs per millisecond, on a single machine, to get IDs longer than 12 chars. UUIDs take 16 bytes, 32 if you encode as strings so 12 is still a bargain.
The automatic scaling of id length based on generation rate is pretty cool, but it has some drawbacks.
When I know my own use case and how important it is to me to avoid a collision, I'd like to be able to skip the timing code and just specify the length myself.
It'd be nice if I could call generate(12), and get output of the specified length. (Or, generateFixed could be its own function, separating out the timing code completely for those who don't want it to be part of their project.)
The text was updated successfully, but these errors were encountered: