Redis › Cluster Sharding & Hash Slots

What are hash slots in Redis Cluster, and how many are there in total?

Beginner

Answer

Redis Cluster divides its entire key space into sixteen thousand three hundred and eighty four hash slots, and every key is assigned to exactly one of these slots based on a hash calculation, with each node in the cluster responsible for owning and serving a specific range of these slots.
-- Check which hash slot a key belongs to
redis-cli cluster keyslot user:123
Real-world example A three node Redis Cluster might divide its sixteen thousand three hundred eighty four hash slots roughly evenly, with each node responsible for owning about five thousand four hundred slots and the keys that map to them.

Common follow-ups: How do you check which specific node currently owns a particular hash slot?;What happens to hash slots when a node is added or removed from the cluster?