Overview of Redis Cluster main components

Keys distribution model

HASH_SLOT = CRC16(key) mod 16384

CRC16 behaved remarkably well in distributing different kind of keys evenly across the 16384 slots.
总之,该方法可以是数据均匀的分配不同的节点上。

Keys hash tags

>Hash tags are a way to ensure that multiple keys are allocated in the same hash slot. This is used in order to implement multi-key operations in Redis Cluster.

rules:

IF the key contains a { character.
AND IF there is a } character on the right of {
AND IF there are one or more characters between the first occurrence of { and the first occurrence of }.

Examples:

{user1000}.following > hash key “user1000”
{user1000}.followers > hash key “user1000”
foo{}{bar} > hash key “foo{}{bar}”
foo{{bar}} > hash key “{bar”
foo{bar}{zap} > hash key “bar”
{}noMatterWhat > hash key while key

tips: 对于二进制key,为了确保整个key都被用于hash,可以另key以“{}”开头。

Cluster nodes attributes

unique name

唯一,当配置文件删除或者强行reset才会改变。

Redirection and resharding

MOVED Redirection

客户端可以向集群中的任何一个节点发消息,包括从节点。
处理过程:
1.能否处理if it is acceptable (that is, only a single key is mentioned in the query, or the multiple keys mentioned are all to the same hash slot)
2.归谁处理(查询slot–>node map)
3.处理,归自己处理,归其他节点处理,执行move指令。
示例:-MOVED 3999 127.0.0.1:6381

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值