当前位置:网站首页>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
边栏推荐
- Network five whip
- 871. Minimum Number of Refueling Stops
- 【主流Nivida显卡深度学习/强化学习/AI算力汇总】
- 【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
- Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things
- [crawler] Charles unknown error
- redis的持久化机制原理
- pytorch-权重衰退(weight decay)和丢弃法(dropout)
- 【TFLite, ONNX, CoreML, TensorRT Export】
- 多表操作-子查询
猜你喜欢

iTOP-3568开发板NPU使用安装RKNN Toolkit Lite2
![[yolov5.yaml parsing]](/img/ae/934f69206190848ec3da10edbeb59a.png)
[yolov5.yaml parsing]
![[deploy pytoch project through onnx using tensorrt]](/img/b6/ec95f028f749753666c7877134ad70.png)
[deploy pytoch project through onnx using tensorrt]

redis的持久化机制原理

分类TAB商品流多目标排序模型的演进

Splunk configuration 163 mailbox alarm

12.(地图数据篇)cesium城市建筑物贴图

Evolution of multi-objective sorting model for classified tab commodity flow

XML parsing

【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
随机推荐
2048游戏逻辑
SET XACT_ ABORT ON
Mongodb replica set
【TFLite, ONNX, CoreML, TensorRT Export】
1个插件搞定网页中的广告
An error is reported in the process of using gbase 8C database: 80000305, host IPS long to different cluster. How to solve it?
Shell script file traversal STR to array string splicing
1 plug-in to handle advertisements in web pages
12. (map data) cesium city building map
Web API配置自定义路由
11. (map data section) how to download and use OSM data
c#操作xml文件
Advanced technology management - what is the physical, mental and mental strength of managers
Solve the problem of slow access to foreign public static resources
yolov5目標檢測神經網絡——損失函數計算原理
[calculation of loss in yolov3]
技术管理进阶——什么是管理者之体力、脑力、心力
7.2 daily study 4
Open3D 网格(曲面)赋色
pytorch训练进程被中断了