I need to generated unique Ids in distributed manner. Some at server side and another at client side. Server side programming language can be ruby and python while client side is javascript. I am plannning to use simpleflake libraries for respective languages.
Can I assume that the ids will never collide?
OR they can collide often, due to the implementation details in different packages?
Thanks in advance.
-Amit
Python's Simpleflake and Node.js's simpleflakes are actually derived from same origin (python's implementation). Both generate 64bit IDs And IDs generated by both are compatible with each other.
The simple flake generates id with the formula
flake = (int((time.time() - 946702800) * 1000) << 23) + random.SystemRandom().getrandbits(23)
As pointed out in earlier answer, the probability of collision is really low (It is the probability of clashing 41 bit timestamp in milliseconds and the probability of randomly generated 23 bit integer).
However, it'd be important to know the difference between two implementations mentioned above. The simpleflakes node.js library fixes its epoch at 2000-01-01T00:00:00.000Z whereas python implementation assumes the epoch at 2000-01-01T05:00:00.000Z.