日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

redis cluster slots数量 为何是16384(2的14次方)

發(fā)布時間:2023/12/13 综合教程 34 生活家
生活随笔 收集整理的這篇文章主要介紹了 redis cluster slots数量 为何是16384(2的14次方) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

  redis cluster集群通過分片的方式來保存數據庫中鍵值對:集群的整個數據庫被分為16384個槽(slot),

數據庫中的每個鍵都屬于這16384個槽的其中一個,集群中的每個節(jié)點可以處理0個或者最多16384個槽

  當數據庫中的16384個槽都有節(jié)點在處理時,集群處于上線狀態(tài)(ok);相反地,如果數據庫中有

任何一個槽沒有得到處理,那么集群處于下線狀態(tài)(fail).

  為什么slots數量是16384(即2的14次方)?

  redis source code author antirez say

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.

翻譯

  1、正常的心跳包攜帶節(jié)點的完整配置,可以用冪等方式替換舊節(jié)點以更新舊配置。 這意味著它們包含原始形式的節(jié)點的插槽配置,它使用帶有16k插槽的2k空間,但使用65k插槽時將使用高達8k的空間。
  2、同時,由于其他設計權衡,Redis Cluster不太可能擴展到超過1000個主節(jié)點。
因此,16k處于正確的范圍內,以確保每個主站有足夠的插槽,最多1000個主站,但足夠小的數字可以輕松地將插槽配置傳播為原始位圖。 請注意,在小型集群中,位圖難以壓縮,因為當N很小時,位圖將設置插槽/ N位,這是設置的大部分位。

總結

以上是生活随笔為你收集整理的redis cluster slots数量 为何是16384(2的14次方)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。