当前位置:网站首页>Redirection of redis cluster
Redirection of redis cluster
2022-07-05 11:44:00 【We've been on the road】
This article mainly introduces redis Clustered Redirect problem .
One 、 The reason for redirection
about Redis In terms of clusters , Because cluster nodes can't proxy (proxy) Command request , So the client should return -MOVED
perhaps -ASK
to turn to (redirection) When it's wrong , Forward the command request to other nodes .
Common optimization methods in use : The client can save the mapping information between key and node , It can effectively reduce the number of possible turns , So as to improve the efficiency of command execution .
When a node needs to make a client long-term (permanently) When a command request for a slot is sent to another node , The node returns... To the client MOVED
to turn to . This situation is usually , When the client requests an operation that does not exist on the current node , We can usually solve this problem by maintaining a mapping relationship between nodes and key values on the client side .
On the other hand , When the node needs to let the client only move to another node in the next command request , The node returns... To the client ASK
to turn to . Here redirection is generally redis When data is being migrated between different nodes in the cluster , To use this ASK to turn to , for example redis When the cluster expands or shrinks .
Two 、MOVED to turn to
One Redis The client can go to any node in the cluster ( Include slave nodes ) Send command request . If the slot you are looking for is not handled by this node , The node will view the hash slot saved in itself to the node ID Mapping records for , And reply to the client with a MOVED
error .
( come from : https://www.huaweicloud.com/articles/38e2316d01880fdbdd63d62aa26b31b4.html)
Execution process :
-
1.Redis A single node of the socket Communications ,
-
Will share Redis Cluster The relationship between the slot and the corresponding node in the cluster .
-
2. Client to Redis Cluster Send commands to any node of the ,
-
The node receiving the command will respond to CRC16 Rules carry out
hash Operation and 16383 Remainder ,
-
Calculate your own slot and corresponding node .
-
3. If the slot that holds the data is assigned to the current node , Then execute the command in the slot ,
-
And return the result of command execution to the client .
-
4. If the slot where the data is stored is not within the management scope of the current node ,
-
Return... To the client moved Redirection exception .
-
5. The client receives the result returned by the node , If it is moved abnormal ,
-
From moved Exception to get the information of the target node .
-
6. The client sends commands to the target node , Get command execution result .
3、 ... and 、ASK to turn to
When the node needs to let the client only move to another node in the next command request , The node returns... To the client ASK
to turn to , Often occurs in data from the node A Migrate to node B When .
( come from : https://www.huaweicloud.com/articles/38e2316d01880fdbdd63d62aa26b31b4.html)
Execution process :
-
1. When a client sends a command to a node in the cluster ,
-
The node returns... To the client moved abnormal , Tell the client the node information of the corresponding target slot .
-
2. The client sends the command to the target node ,
-
The slot in the target node has been migrated to another node , At this point, the target node will return ask Redirect to client .
-
3. Client to new target The node sends Asking command ,
-
Then send the request command to the new node again .
-
4. New node target Carry out orders , Return the result of command execution to the client .
Example :
The slots listed in our previous section 8
In the case of , Because of the slot 8
The bonds contained are scattered in the nodes A And nodes B in , So when the client is at the node A When a key is not found in , It should turn to the node B In search of , But this shift should only affect one command query , Instead of having the client look up the node directly every time B : At the node A What is held belongs to the slot 8
There is no key for All moved to node B Before , The client should access the node first A , Then visit the node B .
Reference documents :
http://redisdoc.com/topic/cluster-spec.html
https://www.huaweicloud.com/articles/38e2316d01880fdbdd63d62aa26b31b4.html
边栏推荐
- Advanced technology management - what is the physical, mental and mental strength of managers
- How to understand super browser? What scenarios can it be used in? What brands are there?
- CDGA|数据治理不得不坚持的六个原则
- Yolov5 target detection neural network -- calculation principle of loss function
- [singleshotmultiboxdetector (SSD, single step multi frame target detection)]
- 7 大主题、9 位技术大咖!龙蜥大讲堂7月硬核直播预告抢先看,明天见
- [deploy pytoch project through onnx using tensorrt]
- [calculation of loss in yolov3]
- [yolov3 loss function]
- Mongodb replica set
猜你喜欢
【使用TensorRT通过ONNX部署Pytorch项目】
pytorch-权重衰退(weight decay)和丢弃法(dropout)
Splunk configuration 163 mailbox alarm
Mongodb replica set
AutoCAD -- mask command, how to use CAD to locally enlarge drawings
Pytorch softmax regression
yolov5目标检测神经网络——损失函数计算原理
Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
Yolov 5 Target Detection Neural Network - Loss Function Calculation Principle
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
随机推荐
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
Yolov5 target detection neural network -- calculation principle of loss function
[calculation of loss in yolov3]
[leetcode] wild card matching
Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
百问百答第45期:应用性能探针监测原理-node JS 探针
【TFLite, ONNX, CoreML, TensorRT Export】
pytorch-多层感知机MLP
pytorch-softmax回归
[mainstream nivida graphics card deep learning / reinforcement learning /ai computing power summary]
ZCMU--1390: 队列问题(1)
ibatis的动态sql
分类TAB商品流多目标排序模型的演进
《看完就懂系列》15个方法教你玩转字符串
7.2 daily study 4
POJ 3176 cow bowling (DP | memory search)
C operation XML file
【load dataset】
石油化工企业安全生产智能化管控系统平台建设思考和建议
网络五连鞭