In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Is the Redis cluster the reason for 16384 slots? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
Instead of using consistent hash, Redis clusters introduce the concept of hash slots. The Redis cluster has 16384 hash slots. Each key is checked by CRC16 and then modulates 16384 to decide which slot to place. Each node of the cluster is responsible for a part of the hash slot. But why is the number of hash slots 16384 (2 ^ 14)? this question has been raised on github, and the author has also given an answer. Let's briefly analyze it.
Why 16384 (2 ^ 14)?
When the redis node sends the heartbeat packet, you need to put all the slots in this heartbeat packet in order to let the node know the current cluster information. 1638416k. When sending the heartbeat packet, using bitmap compression is 2k (2 * 8 (8 bit) * 1024 (1k) = 2K), that is, using 2k space to create the number of 16k slots.
Although a maximum of 65535 (2 ^ 16-1) slots can be allocated using the CRC16 algorithm, 65535mm 65k, which means 8k (8 * 8 (8 bit) * 1024 (1k) = 8K) after compression, that is, 8k heartbeats are required, which is not worth doing; and in general, a redis cluster will not have more than 1000 master nodes, so 16k slots is a more appropriate choice.
The author's original words:
1. The normal heartbeat packet carries the complete configuration of the node, which can be replaced idempotently with the old configuration in order to update the old configuration. This means that they contain the slot configuration of the original node, 16k slot configuration requires 2k memory space, but using 65k slots will use 8k memory space.
2. At the same time, due to other design tradeoffs, it is impossible for a Redis cluster to scale to more than 1000 nodes.
Therefore, 16k is more appropriate to ensure that each main device has enough slots, up to a maximum of 1000. The node configuration information of redis is transmitted through bitmap storage. There is a compression process before transmission. The compression ratio is closely related to the number of slots and nodes (because when N is small the bitmap would have slots/N bits set that is a large percentage of bits set.) [number of slots / nodes] when the N is larger, the compression ratio is smaller.
Thank you for reading! After reading the above, do you have a general understanding of the reason why the Redis cluster has 16384 slots? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
CREATE OR REPLACE Package xxx_STD_AP_AutoPMTs_pkg Is/*=
© 2024 shulou.com SLNews company. All rights reserved.