当前位置:网站首页>A debugging to understand the slot mechanism of redis cluster
A debugging to understand the slot mechanism of redis cluster
2022-07-01 21:57:00 【mariolu】
Once I was testing redis colony ( The redis The cluster uses a batch intel Performance hardware aep), In order to find out the upper limit of performance before going online . So there is the following story .
Under normal circumstances , Because I don't have so many machines to fight redis colony , So I went to seek the help of the pressure testing platform of the testing department , To get large traffic ( In order to simulate the real online , The traffic recorded by bypass is used for playback ), But because the pressure test platform is for business services ( request pb The format is customized by business ), Without this redis Read write pressure measurement function . So we still have to rely on service , But there are not many service machines in our bypass test environment . So there are big data students' suggestions , Can your data all reach the same slot.
Well, this redis Of slot I heard , But I don't know much about , Because I only need one connection at ordinary times url+ The port is done . For example, the following configuration
So , Use gdb Open the service process , Go inside and spy slot How it works
gdb --args ./SearchUserFeatureServer --flagfile=conf/gflags.conf
Set breakpoints , Can press r, Start exploring
First of all, I found that when initializing the connection ,redis Will respond to , Return connection information like this
f2a9484ec91a9007863d015e2f72146940477efb 10.194.88.141:[email protected] master - 0 1656591917000 33 connected 656-1311
It describes
<id><ip:port><flags><master><ping-sent><pong-recv><config-epoch><link-state><slot><slot>...<slot>
So my code will look for this slot, Then proceed slot Of redis node Mapping of nodes . In the end, I'll put this 16384 The array of elements is full .
It's in the code int slot_ipport_index_vec[16384].
First of all, the cluster I connected has 24 individual node, One of them node The information is as follows : His beginning slot yes 656, End slot yes 1311
Each paragraph slot The interval is 656, This 656 It's based on 16384 individual slot Count /24 individual node Got . Look at this 16384 An array , He is evenly distributed 24 individual node. Every node Monopolize a period slot.
First of all, I will go and redis Connect , Then he'll tell you redis How many node
And then this node The quantity will be used as the divisor ,16384/node Count =slot Section
Then each slot Intervals are all connected by the same node . Put this 16384 Divided into 0-655,656-1311,…
Subsequent requests will be based on key Of crc32 Figure out one. hash value , Project to this hash On the ring , Decide which node to use
This is a request key Come in , according to crc16 Do simple hash value calculation
The request will be based on hash Calculate to fall in 16384 The final node of an array of elements , It's like a hash Ring ,node Project once , request key Project once , Then find the intersection
But what I see is and redis establish init The process of , I don't know if it will be added or reduced later node How did you handle it , This needs further study ~
边栏推荐
- burpsuite简单抓包教程[通俗易懂]
- One of the basic learning of function
- 同花顺股票开户选哪个券商好手机开户是安全么?
- BPR(贝叶斯个性化排序)
- List announced | outstanding intellectual property service team in China in 2021
- 最近公共祖先离线做法(tarjan)
- 小 P 周刊 Vol.11
- Difference and use between require and import
- Talking from mlperf: how to lead the next wave of AI accelerator
- [noip2013] building block competition [noip2018] road laying greed / difference
猜你喜欢
Getting started with the lockust series
基于三维GIS的不动产管理应用
【Leetcode】最大连续1的个数
Icml2022 | interventional contrastive learning based on meta semantic regularization
薛定谔的日语学习小程序源码
Go — 相关依赖对应的exe
GCC编译
leetcode刷题:栈与队列03(有效的括号)
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
朋友圈社区程序源码分享
随机推荐
ICML2022 | 基于元语义正则化的介入性对比学习
GCC编译
MIT|256KB 内存下的设备上训练
【opencv】train&test HOG+SVM
编程英语生词笔记本
工控设备安全加密的意义和措施
Test cancellation 1
MQ学习笔记
I received a letter from CTO inviting me to interview machine learning engineer
AIDL基本使用
Accelera Systems Initiative是一个独立的非营利组织
burpsuite简单抓包教程[通俗易懂]
基于K-means的用户画像聚类模型
cmake工程化相关
杰理之烧录上层版物料需要【篇】
功利点没啥!
业务可视化-让你的流程图'Run'起来
【单体】流辰信息I-BPSv3服务器推荐配置
杰理之、产线装配环节【篇】
js数组拼接的四种方法[通俗易懂]