当前位置:网站首页>Globally unique key generation strategy - implementation principle of the sender
Globally unique key generation strategy - implementation principle of the sender
2022-06-25 15:24:00 【Running pig ZC】
background
- Our system is distributed , A globally unique quantity is required to identify a field
- Because of the complexity of the system , We need to understand these key Operation and maintenance
The transmitter
The business process

- Call interface - nextId
- server Go to redis-cluster Get a self increment , And back to
- Obtained by microservice server The value returned , And write it to the database
Basic model

Realization principle
redis Single thread model

Source code
java
com.youzan.paas.march.sdk.BasicClient#next
com.youzan.paas.march.sdk.JedisBackend#incr
redis.clients.jedis.JedisCluster#incr
redis.clients.jedis.Client#incr
redis.clients.jedis.BinaryClient#incr
this.sendCommand(Command.INCR, new byte[][]{
key})
connect();
redis.clients.jedis.Protocol#sendCommand(RedisOutputStream,redis.clients.jedis.Protocol.Command, byte[]...)
c
c_string.incrDecrCommand
getLongLongFromObjectOrReply // have a look key Is there any
value += incr; inct =1, take value+1
dbOverwrite,// Overwrite the original value
Other distributed id
| The algorithm name | Belongs to | Reference material |
|---|---|---|
| snowflake | https://github.com/beyondfengyu/SnowFlake | |
| Leaf | Meituan | https://github.com/Meituan-Dianping/Leaf |
| tinyid | sound of dripping water | https://github.com/didi/tinyid |
| uid-generator | Baidu | https://github.com/baidu/uid-generator |
| … | … |
summary
- This paper introduces the background of the annunciator , And the problems to be solved
- Basic model CS
- Realization principle
- Other Internet companies are distributed id Generation strategy for
边栏推荐
- Core mode and immediate rendering mode of OpenGL
- QT pattern prompt box implementation
- QT file reading -qfile
- 0703 interface automation - MySQL database connection, encapsulation, adding database verification in use cases
- Use Matplotlib to draw a line chart
- 55 specific ways to improve program design (1)
- RDB and AOF persistence of redis
- (2) Relational database
- New title of PTA
- How to deal with mining process
猜你喜欢

Esp8266 building smart home system

C language escape character and its meaning

QT excel table read / write library - qtxlsx

Solution of push code failure in idea

Several common optimization methods

semget No space left on device

Yolov5 Lite: fewer parameters, higher accuracy and faster detection speed

basic_ String mind map

Advertising effect cluster analysis (kmeans)

GDB debugging
随机推荐
Leetcode122 timing of buying and selling stocks II
Using R language in jupyter notebook
Kali modify IP address
Ubuntu 20.04 installing mysql8.0 and modifying the MySQL password
Function of getinstance() method
Daily question, Caesar code,
QT pop up open file dialog box QFileDialog
System Verilog - data type
Why should the coroutine be set to non blocking IO
JMeter reading and writing excel requires jxl jar
Detailed summary of reasons why alertmanager fails to send alarm messages at specified intervals / irregularly
Common operations in VIM
QT opens the print dialog box in a text editor
Stderr and stdout related standard outputs and other C system APIs
iconv_ Open returns error code 22
Agent and classloader
Yolov3 spp Darknet version to caffemodel and then to OM model
About%*s and%* s
System Verilog - thread
Js- get the mouse coordinates and follow them