From 008fe45df13239b313727f79a14eab6ad2f18c54 Mon Sep 17 00:00:00 2001 From: asahi Date: Tue, 30 Sep 2025 15:20:09 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E9=98=85=E8=AF=BBredis=20cluster=20repl?= =?UTF-8?q?cia=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 中间件/redis/redis.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/中间件/redis/redis.md b/中间件/redis/redis.md index 3f7d027..3fc2376 100644 --- a/中间件/redis/redis.md +++ b/中间件/redis/redis.md @@ -225,6 +225,7 @@ - [Client connections and redirection handling](#client-connections-and-redirection-handling) - [CLUSTER SLOTS](#cluster-slots) - [Multi-keys operations](#multi-keys-operations) + - [Scaling reads using replica nodes](#scaling-reads-using-replica-nodes) # redis @@ -3586,3 +3587,14 @@ MSET {user:1000}.name Angela {user:1000}.surname White 当指定hash slots的迁移完成后,关于该hash slot所有的`multi-key operations`都允许被执行。 +#### Scaling reads using replica nodes +通常来讲,replica nodes在接收到命令时,都会将其重定向给负责该hash slot的master node。但是,对于readonly命令,client可以使用replicas来对读操作进行扩展。 + +`READONLY`会告知redis cluster replica node如下信息:当前client`接收读取可能过时的数据`,并且`不会发送写请求`。 + +当connection处于readonly模式时,cluster只会在`the operation involves keys not served by the replica's master node`时,才会向client发送重定向。造成该问题的原因可能如下: +- the client sent a command about hash slots never served by the master of this replica +- the cluster was reconfigured and the replica is no longer able to serve commands for a given hash slot + +当发生该场景时,replica会向client发送重定向,而client则应该更新其`hash slot map`。 +