当前位置:网站首页>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 .
边栏推荐
- 卡特兰数(Catalan)的应用场景
- [set theory] partition (partition | partition example | partition and equivalence relationship)
- 2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
- Interface learning
- Laravel frame step pit (I)
- mongodb
- Software testing learning - day 3
- 2022 East China Normal University postgraduate entrance examination machine test questions - detailed solution
- centos php7.3安装redis扩展
- Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
猜你喜欢

IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library

How to migrate or replicate VMware virtual machine systems

Create your own deep learning environment with CONDA

JMeter JSON extractor extracts two parameters at the same time

Ruoyi interface permission verification

Summary of UI module design and practical application of agent mode

Asynchronous programming: async/await in asp Net

How to specify the execution order for multiple global exception handling classes
![[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle](/img/f8/0e3fbfd13bf06291a73200552ff17a.png)
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle

Pits encountered in the use of El checkbox group
随机推荐
Basic teaching of crawler code
100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
保险公司怎么查高血压?
Unittest attempt
Laravel Web框架
[set theory] partition (partition | partition example | partition and equivalence relationship)
JMeter JSON extractor extracts two parameters at the same time
SQL implementation merges multiple rows of records into one row
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
Unit test notes
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
The essence of interview
php artisan
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
Create your own deep learning environment with CONDA
MySQL installation
Simple understanding of bubble sorting
【code】偶尔取值、判空、查表、验证等
CentOS php7.3 installing redis extensions