Generating unique id's
Content:
Original link: How to Generate Unique IDs in Distributed Systems / AlgoMaster.
The article covers some basic mechanisms.
It does not cover one of the best approaches the hi/lo approach.
The hi/lo approach:
- the unique id consist of a high part and a low part (32 + 32 bit or 48 + 16 bit or 96 + 32 bit or whatever
- the high part is generated using an relativ expensive database operation
- when a node get the high part it "owns " all id's with that high part and generate low part sequentiall
- when a node reach max low part it just request a new high part
- does a node crash then not all low parts for the in use high part will be used but there are plenty of high parts available
This approach has been known for 20+ years and are supported in many persistence frameworks.
Wikipedia
Comments: