# 拼多多面试：为什么RedisCluster有16384个槽?

：你知道为什么RedisCluster有 16384

：应该是作者脑袋一热随意定的一个数值吧？（心里嘀咕：如果 antirez

：。。。，今天的面试就到这里，你回去等消息吧

：。。。

## 引言

，计算出映射到哪个分片上，然后Redis会去相应的节点进行操作！

ps
: CRC16

65536，而选择 mod
16384？

https://github.com/antirez/redis/issues/2576

The reason is:

• Normal heartbeat packets carry the full configuration of a node, that can be replaced in an idempotent way with the old in order to update an old config. This means they contain the slots configuration for a node, in raw form, that uses 2k of space with16k slots, but would use a prohibitive 8k of space using 65k slots.
• At the same time it is unlikely that Redis Cluster would scale to more than 1000 mater nodes because of other design tradeoffs.

So 16k was in the right range to ensure enough slots per master with a max of 1000 maters, but a small enough number to propagate the slot configuration as a raw bitmap easily. Note that in small clusters the bitmap would be hard to compress because when N is small the bitmap would have slots/N bits set that is a large percentage of bits set.

## 正文

### 基础

127.0.0.1:7000>cluster meet 127.0.0.1:7001

，如下图所示。