Redis › Cluster Sharding & Hash Slots
How does Redis Cluster determine which hash slot a specific key belongs to?
IntermediateAnswer
Redis Cluster applies a hashing algorithm called CRC16 to the key, then takes the result modulo sixteen thousand three hundred eighty four to determine the specific hash slot, ensuring keys are distributed pseudo randomly but consistently across the entire cluster's available slots.
-- The hash slot calculation happens automatically
-- CRC16(key) mod 16384 determines the slot
redis-cli cluster keyslot session:abc123Real-world example A developer troubleshooting uneven load across cluster nodes checks the hash slot calculation for their most frequently accessed keys, discovering a naming pattern that was accidentally concentrating too many keys onto a single node.