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.
Previous
What does the Redis INFO command return?
Next
What is the difference between Redis Sentinel and Redis Cluster?
More Redis Questions
View all →- Intermediate What is the difference between Redis Sentinel and Redis Cluster?
- Intermediate How do MULTI and EXEC work in Redis transactions?
- Intermediate What is WATCH and optimistic locking in Redis?
- Intermediate What is Lua scripting in Redis and when should you use it?
- Intermediate What are Redis eviction policies?