Hello! I started the challenges yesterday, and am confused about how we’re ensuring globally unique ID generation, in a situation where we have multiple generator nodes. To keep it simple, I am using UUIDs (uuid.New() from google/uuid in Golang).
For a single node, just throwing these UUIDs seem sufficient as it’s rare to have collisions.
For multiple nodes, how do we ensure consistency for this task? If I generate some id a from Node 1, and want Node 2 to avoid generating it, should I use a DB, or some centralised bloom filter?
In this case, how do I go about setting up a centralised data storage for this assignment? A plaintext file?
I’m fairly new to distributed systems, and am doubtful of my approach to the solution. It would be great if someone could share their thoughts here. Thank you.
I’m currently using uuid.New() which is compliant with uuid4. Can you help me understand how using this function in multiple nodes (independent tasks) still ensures global uniqueness without any node communicating about these IDs?
Just by sheer numbers - 122 bits. Even if you have thousands of nodes the probability of collision is extremely low. But a unique constraint in your DB and you’ll be guaranteed to be unique.
Yep, generally the chance of anyone having a UUID collide with anyone else, let alone yourself, is low enough to accept. Wikipedia has some good numbers here: Universally unique identifier - Wikipedia
only after generating 1 billion UUIDs every second for approximately 100 years would the probability of creating a single duplicate reach 50%