继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

redis之槽个数

Naison
关注TA
已关注
手记 5
粉丝 2
获赞 9
  • redis的槽的个数是16384个,为什么呢?2^14个?

The reason is:

  1. 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.

  2. 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.

Google翻译为:

原因是:正常的心跳包携带节点的完整配置,可以用旧的幂等方式替换以更新旧配置。 这意味着它们包含原始形式的节点的插槽配置,它使用2k空间和16k插槽,但使用65k插槽将占用8k空间。 同时,由于其他设计权衡,Redis Cluster不太可能扩展到超过1000个主节点。 所以16k在正确的范围内确保每个主站有足够的插槽,最多1000个主,但是足够小的数字可以很容易地将插槽配置传播为原始位图。 请注意,在小型集群中,位图难以压缩,因为当N很小时,位图将设置插槽/ N位,这是设置的大部分位。

数学:

2k空间 = 2k byte = 2 * 1024 byte = 2 * 1024 * 8 bit = 2^14 bit = 16384 bit = 16384个槽

16k插槽 = 16k个 = 16k bit = 16 * 1024 bit = 16 * 1024 / 8 byte = 2k byte

同理:

65k个插槽 = 65k bit = 8k byte = 8k空间


打开App,阅读手记
1人推荐
发表评论
随时随地看视频慕课网APP