当前位置:网站首页>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 .
边栏推荐
- The essence of interview
- Software testing assignment - day 1
- Upgrade CentOS php7.2.24 to php7.3
- Ruoyi interface permission verification
- [set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*
- centos php7.2.24升级到php7.3
- [LeetCode]404. Sum of left leaves
- Hands on redis master-slave replication, sentinel master-slave switching, cluster sharding
- 2022-06-23 VGMP-OSPF-域间安全策略-NAT策略(更新中)
- DBNet:具有可微分二值化的实时场景文本检测
猜你喜欢
![[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones](/img/d0/850e095a43610366d6144b2471f3f7.jpg)
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones

SQL implementation merges multiple rows of records into one row

Liang Ning: 30 lectures on brain map notes for growth thinking

2022年华东师范大学计科考研复试机试题-详细题解

Inno Setup 制作安装包

2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)

Ruoyi interface permission verification

JMeter test result output

机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)

Reading notes of "learn to ask questions"
随机推荐
Resttemplate configuration use
CentOS switches and installs mysql5.7 and mysql8.0
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
Unittest attempt
Use the jvisualvm tool ----- tocmat to start JMX monitoring
The 10000 hour rule won't make you a master programmer, but at least it's a good starting point
My 2020 summary "don't love the past, indulge in moving forward"
Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
多个全局异常处理类,怎么规定执行顺序
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list
Modify MySQL password
[LeetCode]404. Sum of left leaves
Dbnet: real time scene text detection with differentiable binarization
PHP install composer
修改MySQL密码
万卷书 - 价值投资者指南 [The Education of a Value Investor]
Mise en place d'un environnement de développement de fonctions personnalisées
Crontab scheduled task
Heap sort and priority queue
How to specify the execution order for multiple global exception handling classes