redis slot slot spot

Redis cluster built 16384 hash slot, when a key-value needs to be placed in the cluster Redis

 

When, redis first use crc16 algorithm to calculate a result key, then the result of the remainder number 16384,

Thus a number corresponding to each key will hash the groove between 0-16383, redis according to the number of nodes will be larger

Induced uniform hash slot mapped to different nodes.

Redis cluster does not use consistent hash, but introduces the concept of hash slots.

Cluster Redis hash slots 16384, 16384 for each key by the CRC16 checksum modulo to determine which slot placed. Each node of the cluster is responsible for a portion of the slot hash. This structure can easily add or delete nodes, and whether to add a node to delete or modify certain, will not cause the state of the cluster unavailable.

The benefits of using a hash slots is that you can easily add or remove nodes.

When you need to add nodes, just need some hash slot moved to the new node to other nodes on it;

When you need to remove the node, just need to remove the hash slot in the node moved to other nodes on the line;

At this point, we later add or remove nodes without first turning off all the time redis service.

 

 

"With the concept of a hash slot, but did not use consistent hashing algorithm, not all hash it? The reason for this is why?"
Redis Cluster do their own simple crc16 hash algorithm, there is no consistency with hash. Redis authors think it's crc16 (key) mod 16384 effect has been pretty good, although there is no consistency hash flexible, but the implementation is very simple, and very easy to deal with when the node additions and deletions.

"In order to dynamically add or delete nodes when the data will not lose it?"
Without loss of data and hash algorithm nothing to add or delete a node, without loss of data required is a multiple copies of data.

"There are a total of 14 cluster power of 2, 16384 hash slots, then each hash stored key slot and what is the value?"
When you join a Key to the Redis Cluster, based on crc16 (key ) mod 16384 to calculate this key should be distributed to which the hash slot in a hash slot there will be a lot of key and value. You will be appreciated that as the partition table, when using a single node redis when only one table, all of the key are placed in this list; 16384 will automatically generate the partition table after you use Redis Cluster, you can insert the data in accordance with the above simple algorithm to determine which partition your key should exist, each district has a lot of key.

Guess you like

Origin www.cnblogs.com/php-linux/p/11457317.html