当前位置:网站首页>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-1311It 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 ~
边栏推荐
猜你喜欢

I received a letter from CTO inviting me to interview machine learning engineer

Spark面试题

小 P 周刊 Vol.11

leetcode刷题:栈与队列02(用队列实现栈)

Halcon知识:三维重构的一个尝试

Slf4j打印异常的堆栈信息

Application of real estate management based on 3D GIS

柒微自动发卡系统源码

杰理之烧录都使用 VBAT 供电,供电电压 4.2V【篇】
![[deep learning] use deep learning to monitor your girlfriend's wechat chat?](/img/03/ecf50eacc91c0633b0d9689cdad2c2.png)
[deep learning] use deep learning to monitor your girlfriend's wechat chat?
随机推荐
Classify boost libraries by function
二叉树的基本操作
九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
MIT|256KB 内存下的设备上训练
leetcode刷题:栈与队列02(用队列实现栈)
"The silk road is in its youth and looks at Fujian" is in the hot collection of works in the Fujian foreign youth short video competition
Spark面试题
【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
【深度学习】利用深度学习监控女朋友的微信聊天?
[noip2013] building block competition [noip2018] road laying greed / difference
js如何获取集合对象中某元素列表
打出三位数的所有水仙花数「建议收藏」
在技术升级中迎合消费者需求,安吉尔净水器“价值战”的竞争之道
An operation tool used by we media professionals who earn 1w+ a month
Talking from mlperf: how to lead the next wave of AI accelerator
MQ学习笔记
Internet of things RFID, etc
【Leetcode】最大连续1的个数
Significance and measures of security encryption of industrial control equipment
新版图解网络PDF即将发布