doc: 阅读redis cluster文档

This commit is contained in:
asahi
2025-09-30 16:28:31 +08:00
parent 008fe45df1
commit dc90ad42c2

View File

@@ -226,6 +226,8 @@
- [CLUSTER SLOTS](#cluster-slots) - [CLUSTER SLOTS](#cluster-slots)
- [Multi-keys operations](#multi-keys-operations) - [Multi-keys operations](#multi-keys-operations)
- [Scaling reads using replica nodes](#scaling-reads-using-replica-nodes) - [Scaling reads using replica nodes](#scaling-reads-using-replica-nodes)
- [Fault Tolerance](#fault-tolerance)
- [Heartbeat and gossip message](#heartbeat-and-gossip-message)
# redis # redis
@@ -3598,3 +3600,19 @@ MSET {user:1000}.name Angela {user:1000}.surname White
当发生该场景时replica会向client发送重定向而client则应该更新其`hash slot map` 当发生该场景时replica会向client发送重定向而client则应该更新其`hash slot map`
### Fault Tolerance
#### Heartbeat and gossip message
redis cluster nodes会持续的交换ping和pong packets。ping packet和pong packet的结构相同都包含configuration information。ping packet和pong packet的唯一区别为message type field。
> `ping packets和pong packets被统称为heartbeat packets`。
通常在node发送ping packets时将会导致receiver返回一个pong packet。但是`node也能够在未接收到ping packets的情况下发送pong packets`,用于向其他节点发送其自身的配置信息。在对`new configuration`进行广播时,该机制十分有用。
通常每过几秒node都会随机ping一系列其他节点。故而不管集群的规模如何每个节点发送的ping packets都是恒定的。node并不会因为集群规模扩大向集群所有其他节点发送ping packets导致ping packets的总数上升
但是every node makes sure to ping every other node that hasn't sent a ping or received a pong for longer than `NODE_TIME / 2` time。在`NODE_TIME`到期之前node也会对其他节点尝试重新连接确保其他节点不会因为当前tcp连接的问题而将其他节点判定为不可访问。
`NODE_TIME`设置的较小时,消息交换会更加频繁,且当节点数量较多时,信息交换的数量可能会相当庞大。因为没过`NODE_TIME / 2`时间每个节点都要ping所有其他节点以获取最新的消息。
例如在一个规模为100的集群中如果将`node timeout`设置为60s每个节点在每30s都会尝试发送99个ping故而每个节点每秒钟平均发送`3.3`个ping整个集群每秒钟平均发送`330`个ping。