Back to results for “Performance”
Redis › Cluster Sharding & Hash Slots

How does Redis Cluster determine which hash slot a specific key belongs to?

Intermediate

Answer

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:abc123
Real-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.

Common follow-ups: What is a hash tag, and how does it let you force related keys into the same slot?;Can you manually move a hash slot from one node to another?