🔴 Redis Intermediate

What is Redis Cluster and how does it shard data?

Answer

Redis Cluster is Redis's built-in horizontal scaling solution that automatically partitions data across multiple nodes. It uses a fixed keyspace of 16,384 hash slots. When a key is written, Redis computes CRC16(key) % 16384 to determine the slot. Each master node owns a range of slots — in a 3-master cluster, node A owns slots 0–5460, node B 5461–10922, node C 10923–16383. Each master has one or more replicas for high availability. The client is redirected with a MOVED response if it hits the wrong node. Cluster also supports hash tags: keys with the same content inside {} always land on the same slot, enabling multi-key operations like MSET {user:1}:name and {user:1}:email to coexist on one node.