当前位置:网站首页>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)的应用场景
- Centos切换安装mysql5.7和mysql8.0
- 2021 year end summary
- HMS core helps baby bus show high-quality children's digital content to global developers
- [day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
- Ruoyi interface permission verification
- 爬虫代码基础教学
- Sorting out the core ideas of the pyramid principle
- Notes on the core knowledge of Domain Driven Design DDD
- What are the characteristics and functions of the scientific thinking mode of mechanical view and system view
猜你喜欢

Golang operation redis: write and read hash type data

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

Mise en place d'un environnement de développement de fonctions personnalisées

EasyExcel
![[set theory] partition (partition | partition example | partition and equivalence relationship)](/img/f0/c3c82de52d563f3b81d731ba74e3a2.jpg)
[set theory] partition (partition | partition example | partition and equivalence relationship)

Create your own deep learning environment with CONDA

Summary of UI module design and practical application of agent mode

Journal quotidien des questions (11)

JMeter JSON extractor extracts two parameters at the same time

IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
随机推荐
Software testing learning - day one
每日刷题记录 (十一)
Win 10 find the port and close the port
[Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
Setting up the development environment of dataworks custom function
【code】偶尔取值、判空、查表、验证等
Laravel Web Framework
crontab定时任务
PHP install composer
Inno Setup 制作安装包
JMeter JSON extractor extracts two parameters at the same time
Stream stream
Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
vmware虚拟机C盘扩容
[set theory] partition (partition | partition example | partition and equivalence relationship)
保险公司怎么查高血压?
Troubleshooting of high CPU load but low CPU usage
UTC时间、GMT时间、CST时间
error C2017: 非法的转义序列