Redis Cluster shards data across 16384 hash slots.
Setup¶
redis-cli --cluster create \
10.0.1.1:6379 10.0.1.2:6379 10.0.1.3:6379 \
10.0.1.4:6379 10.0.1.5:6379 10.0.1.6:6379 \
--cluster-replicas 1
Operations¶
redis-cli -c -h 10.0.1.1
CLUSTER INFO
CLUSTER NODES
Limitations¶
- Multi-key ops → hash tags {user}:1
-
Transactions only within one slot
-
Sentinel — HA without sharding
- Cluster — HA + sharding
- Managed — ElastiCache, Azure Cache
Production Operations¶
In production environments, deploy Redis Cluster with at least 6 nodes — 3 masters and 3 replicas for automatic failover. If a master fails, its replica takes over the slot and service continues without downtime. To add capacity, use redis-cli --cluster add-node and then --cluster reshard to redistribute slots.
When developing applications with Redis Cluster, remember hash tags — if you need multi-key operations (MGET, transactions), all keys must be in the same slot. Achieve this by naming keys with hash tags: {user:123}:profile and {user:123}:sessions will be in the same slot. For simpler HA without sharding, consider Redis Sentinel, which provides automatic failover with a single master node.
Cluster for Scale¶
Sentinel for HA, Cluster for horizontal scaling.