4 ms·
In distributed systems, you can easily deal with this by assigning each client node an ordinal, and the client generates a sequential id that is a multiple of t
by vox_mollis 11y ago
In distributed systems, you can easily deal with this by assigning each client node an ordinal, and the client generates a sequential id that is a multiple of the highest ordinal of the ring added to the client's local ordinal. You can synchronize ordinal values between nodes with something like zookeeper or etcd.
- lostcolony 11y agoIf you're having to synchronize it using a strongly consistent mechanism, couldn't you just use an auto-incrementing integer anyway (not meaning to be snarky here - I legitimately don't know)? The benefit of a UUID is you don't need strong consistency; even on a partition of < n+1 nodes you can still generate IDs, and even if the network is unpartitioned, you can generate an ID without making a roundtrip. I would also debate your use of the word 'easily'; what's easier, setting up zookeeper/etcd, or just generating a UUID? But yes, if your use case is "I want to make sure I have non-conflicting IDs across my cluster", synchronizing them is a possible solution. And the right one, if your requirements stipulate absolute ordering based on the generation of each ID.
- jerven 11y agoYou would need to synchronize less often and that can be big benefit performance wise. i.e. you can tolerate more partitions without effects. If done right and in some cases you can have the same benefits as UUIDs with smaller keysizes. After all UUIDs only make it unlikely that you have conflicting IDs not impossible. Especially if your random source is not that random.
- jacquesm 11y agoAuto-incrementing using some kind of centralized store is synchronous, UUID generation is asynchronous.
- jacques_chester 11y agoIn which case, you could equally use v1 or v5 UUIDs. Plus a UUID can be generated by a source outside your network -- eg, client side, with the ability to treat them as quasi-nonces for replay detection. Or inside your network, during long-running partitions. The bigger question is: why would I install, manage, update, monitor zookeeper/etcd and write my own custom ID generator and all the storage mechanisms around it, when I can just use UUIDs?
- vox_mollis 11y agoRight, but I'm addressing the parent case in which ordered id is required (for whatever use case)
- jacques_chester 11y agov1 UUIDs are ordered.
- the_mitsuhiko 11y agoOur clients come and go and are largely unknown to us. Even in that case what you are describing is UUID1.