当前位置:网站首页>Distributed ID
Distributed ID
2022-07-03 06:59:00 【W_ Meng_ H】
Catalog
Two 、 Database autoincrement sequence
One 、UUID
- Current date and time --- Time stamp
- The time series --- Counter
- Globally unique IEEE Machine identification number , If there is a network card , From the network card MAC The address for
advantage :
- The code is simple , Good performance ( Locally generated , No network consumption ), Ensure that the only ( Relatively speaking )
shortcoming :
- Every time I generate ID It's all out of order , And not all numbers , And there is no guarantee that the trend will increase ;UUID The result is a string , Poor string storage performance , Query efficiency is slow ;UUID It's too long , Not suitable for storage , Consume database performance ;ID No business implications , Poor readability ; There are information security issues , It may leak MAC Address .
Two 、 Database autoincrement sequence
standalone mode :
advantage :
- Implement a simple , Rely on the database , The cost is small .
- ID Digitization , Monotonic self increasing , Meet database storage and query performance .
- It has certain business readability .( Combined business code)
shortcoming :
- Strong dependence DB, There is a single problem , If the database goes down , The service is not available .
- DB Generate ID Limited performance , Single point database is under great pressure , Unable to carry high concurrency scenarios .
- Information security issues , For example, expose the order quantity ,url Change the query id Find other people's orders .
Database high availability : Multi master mode for load , Start value and step size setting based on sequence , Different initial values , Same step size , The step size is greater than the number of nodes .
advantage :
- It's solved ID Generated single point problem , At the same time, the load is balanced .
shortcoming :
- System expansion is difficult , After the system defines the step size , Difficulty in adjusting step size after adding machine .
- Database pressure , Get one at a time ID Must read and write the database once .
- When the master and slave are synchronized , This data cannot be found due to data synchronization delay .
3、 ... and 、redis、zk
be based on redis Atomic operation of
be based on zk Of ZNode node
Four 、 Snowflake algorithm
64bit Integer number of , The first sign bit is fixed to 0,41 A time stamp ,10 position workId,12 A serial number . The number of bits can be implemented differently .
advantage :
- Each millisecond value contains ID It's worth a lot of , Not enough, you can change the number of digits to increase , Good performance ( rely on workId Realization ).
- The time stamp is high , In the middle is a fixed machine code , The self increasing sequence is in the low order , Whole ID It's an increasing trend .
- Flexible layout of database nodes according to business scenarios bit Bit Division , High flexibility .
shortcoming :
- Strongly dependent on machine clock , If the clock goes back , Will lead to repeated ID Generate , Therefore, the algorithm based on this is generally used to find clock callback , Will throw exception handling , prevent ID Generate , This may cause the service to become unavailable .
边栏推荐
- Journal quotidien des questions (11)
- Abstract learning
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
- Stream stream
- [untitled]
- 修改MySQL密码
- dataworks自定义函数开发环境搭建
- My 2020 summary "don't love the past, indulge in moving forward"
- Laravel frame step pit (I)
- Yolov3 learning notes
猜你喜欢
Application scenarios of Catalan number
Realize PDF to picture conversion with C #
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
Personally design a highly concurrent seckill system
Daily question brushing record (11)
Yolov2 learning and summary
La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
随机推荐
10000小时定律不会让你成为编程大师,但至少是个好的起点
[Code] occasionally take values, judge blanks, look up tables, verify, etc
[LeetCode]404. 左叶子之和
Flask Foundation
La loi des 10 000 heures ne fait pas de vous un maître de programmation, mais au moins un bon point de départ
Tool class static method calls @autowired injected service
PHP install the spool extension
The essence of interview
Class and object summary
Inno setup production and installation package
Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
CentOS switches and installs mysql5.7 and mysql8.0
Software testing assignment - day 3
mysql误删root账户导致无法登录
HMS core helps baby bus show high-quality children's digital content to global developers
2022年华东师范大学计科考研复试机试题-详细题解
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Notes on the core knowledge of Domain Driven Design DDD
Practice of enterprise ab/testing platform
IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library