In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Why is the maximum number of slots in a redis cluster 16384? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
Instead of using consistent hash, Redis clusters introduce the concept of hash slots.
The Redis cluster has 16384 (2 ^ 14) hash slots. Each key uses the 16384 module after CRC16 verification to decide which slot to place. Each node of the cluster is responsible for part of the hash slot.
This structure is easy to add or delete nodes, and whether you add, delete or modify a node, it will not cause the cluster to be unavailable.
HASH_SLOT = CRC16 (client key) mod 16384
The hash values generated by the CRC16 algorithm are 16bit, which can be generated in the range of 0,65535.
When the redis node sends the heartbeat packet, you need to put all the slots in this heartbeat packet to let the node know the current cluster information. 1638416k. When sending the heartbeat packet, using char for bitmap compression is 2k (2 * 8 (8 bit) * 1024 (1k) = 2K), that is, using 2k space to create 16k slots.
65535mm 65k, which is 8k (8 * 8 (8 bit) * 1024 (1k) = 8K) after compression, that is, an 8k heartbeat packet is required.
Redis Cluster principle
1.node1 and node2 first shake hands with meet, knowing each other's existence.
two。 After a successful handshake, the two nodes will periodically send ping/pong messages and exchange data information (message header, message body)
3. There is a field in the header: unsigned char MyLots [cluster _ SLOTS/8]. Each bit represents a slot. If the bit is 1, it means that the slot belongs to this node.
4. The message body will carry a certain number of other nodes, accounting for about 1/10 of the total number of cluster nodes, or at least 3 nodes. The greater the number of nodes, the larger the body of the message.
5. Ping messages are being sent every second. Five nodes are randomly selected per second to find out which node has not communicated for the longest time to send ping messages.
6. The list of local nodes is scanned every 100ms. If it is found that the last time a node receives a pong message is longer than cluster-node-timeout/2, it is almost impossible for the number of master nodes in the redis cluster to immediately send ping messages to exceed 1000, which may lead to network congestion.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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
© 2024 shulou.com SLNews company. All rights reserved.