当前位置:网站首页>Distributed ID solution

Distributed ID solution

2022-07-07 06:50:00 Knock the little crisp of the code

Distributed id problem

It's mainly the problems caused by sub database and sub table . After the same business data table , Also ensure the data of different tables id only . Otherwise, business data of the same type , Data taken out id It's all the same , How to distinguish these data ?

Solution

Snowflake algorithm :
Unique generated based on timestamp and machine code id. Basic guarantee id Increasing . But when the server time calls back , There may be duplication id.
In response to this question , Baidu UIDGenerator With meituan Leaf Provides a solution , For business scenarios with high requirements , These two solutions can be used .

UUID
It's guaranteed to be unique , But it wastes too much performance .

redis&&Zookeeper
utilize redis or zookeeper Self increasing characteristics of

summary

The most recommended is the snowflake Algorithm . If not sensitive to time callback , Use the snowflake algorithm

原网站

版权声明
本文为[Knock the little crisp of the code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070235111280.html