Single Cache Layer → Distributed Cache
MediumEvolving from a single Redis node (or small cluster) to a distributed cache topology using consistent hashing, enabling horizontal memory scaling, geographic distribution, and cache isolation between workload types: at the cost of increased operational complexity and potential hotspot concentration.
Topology Changes
From
Single Redis Node / Sentinel Cluster
To
Distributed Redis Cluster (Consistent Hash Ring)
Topology Mutations
Single Redis node replaced by 3-6 primary shards each with a replica
Operational Impact
Consistent hash ring distributes keys across shards; adding/removing a node requires key migration (~15-30% of keys rehash)
Client library routes each cache key to the correct shard using consistent hashing
Operational Impact
MGET and pipelines that span multiple keys may hit multiple shards: multi-key commands require client-side scatter-gather
Redis Cluster status monitoring required: CLUSTERINFO, connected nodes, slot migration status
Operational Impact
Node failure triggers automatic failover to replica; failover window ~10-30s during which those keys miss
Dedicated shards for high-priority workloads (session cache isolated from product cache)
Operational Impact
Session cache eviction no longer triggered by product catalog warm-ups; memory allocation is explicit per shard
Migration Stages
Analyze existing cache key patterns and sizes. Map key namespaces to expected shard assignments. Identify multi-key operations (MGET, pipelines) that will require scatter-gather after sharding.
Deploy Redis Cluster with 3 primary shards and 3 replicas minimum. Configure memory limits per shard. Verify cluster topology via CLUSTER INFO. Set up cluster health monitoring and alerting.
Update application to use cluster-aware Redis client. Test all cache operations including multi-key commands (MGET, MSET, pipelines). Update MGET to scatter-gather pattern if keys span multiple shards.
Gradually migrate cache writes from single node to cluster. Accept cold-start miss rate increase as cluster warms up. Monitor hit rate recovery.
Drain remaining traffic from single node. Verify cluster hit rate matches pre-migration single-node hit rate. Decommission single node.
Migration Risks
Adding or removing cluster nodes causes consistent hash ring rebalancing: temporary cache miss spike
Mitigation
Schedule node additions during low-traffic windows; pre-warm new nodes with key migration before announcing to clients
Multi-key operations (MGET) cannot span shards in a single command: requires client-side scatter-gather
Mitigation
Audit all MGET, MSET, and pipeline operations before migration; implement scatter-gather in application code
Cluster slot migration during rebalancing causes temporary key unavailability (MOVED error)
Mitigation
Client library handles MOVED errors automatically with retry; verify client library cluster support before migration
Coupling Changes
Cluster topology changes (node add/remove) require coordinated slot migration
Consequence
Cache capacity changes are no longer zero-touch: require planned migration windows
Workload memory isolation prevents one workload from evicting another's hot keys
Consequence
Session cache hit rate is stable even during product catalog warm-up spikes
Consistency Model Changes
- ·Single-node Redis was not strongly consistent across replicas: cluster replication is also asynchronous
- ·Node failover introduces a brief window where keys on the failed primary shard are unavailable
- ·Cluster remains available during single-node failure: only the affected key slot range is impacted
Rollback Risks
- ·Application client library changes require code rollback: cannot be reversed without a deployment
- ·Cache keys written to cluster after single-node decommission have no fallback
- ·Cluster-mode MGET scatter-gather cannot be rolled back without restoring scatter-gather code