5 Tweets 7 reads Dec 24, 2022
/1 How do we generate unique IDs in distributed systems? How do we avoid ID conflicts?
The diagram below shows 5 ways. πŸ‘‡
/2 Assume the design requirements of distributed unique ID are:
1. Globally unique.
2. Availability. The ID generator must be available under high concurrency.
3. Ordered. The IDs are sorted by certain rules. For example, sorted by time.
/3 4. Distributed. The ID generator doesn’t rely on a centralized service.
5. Security. Depending on the use case, some IDs cannot be incremental integers, which might expose sensitive info. For example, people might guess the total user number correctly by looking at the IDs.
/4 Over to you: 1) Could you think of any use cases that unique IDs are useful?
2οΌ‰There are variations in the snowflake implementation. For example, data center ID can be added to the β€œMachineID” section to guarantee global uniqueness. Do you know other variations?
/5 I hope you've found this thread helpful.
- Like/Retweet the first tweet below if you can.
- Follow me @alexxubyte for more.
- I write about system design and book writing tips.

Loading suggestions...