当前位置:网站首页>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 .
边栏推荐
- Gridome + strapi + vercel + PM2 deployment case of [static site (3)]
- 服务器如何设置多界面和装IIS呢?甜甜给你解答!
- [classes and objects] explain classes and objects in simple terms
- [Fiddler problem] solve the problem about Fiddler's packet capturing. After the mobile network is configured with an agent, it cannot access the Internet
- [attribute comparison] defer and async
- Realize PDF to picture conversion with C #
- Architecture notes
- Stream stream
- dataworks自定義函數開發環境搭建
- Thoughts in Starbucks
猜你喜欢

Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record

EasyExcel

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

Golang operation redis: write and read kV data

10000小時定律不會讓你成為編程大師,但至少是個好的起點

vmware虚拟机C盘扩容

VMware virtual machine C disk expansion

卡特兰数(Catalan)的应用场景

Create your own deep learning environment with CONDA
![[classes and objects] explain classes and objects in simple terms](/img/41/250457530880dfe3728432c2ccd50b.png)
[classes and objects] explain classes and objects in simple terms
随机推荐
CentOS php7.3 installing redis extensions
Golang operation redis: write and read kV data
Modify MySQL password
DBNet:具有可微分二值化的实时场景文本检测
Summary of UI module design and practical application of agent mode
Reading notes of "learn to ask questions"
Integration test practice (1) theoretical basis
Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
Yolov3 learning notes
Setting up the development environment of dataworks custom function
Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
Software testing assignment - day 3
Win 10 find the port and close the port
crontab定时任务
Software testing learning - the next day
HMS core helps baby bus show high-quality children's digital content to global developers
C2338 Cannot format an argument. To make type T formattable provide a formatter<T> specialization:
In depth analysis of reentrantlock fair lock and unfair lock source code implementation
MySQL installation
[set theory] equivalence classes (concept of equivalence classes | examples of equivalence classes | properties of equivalence classes | quotient sets | examples of quotient sets)*