Redis Architecture Design Guide — Standalone to Cluster
Practical comparison of Redis Standalone, Sentinel, and Cluster architectures. Differences explained and selection criteria by service scale from an engineering perspective.
TestForge Team ·
Three Redis Architectures
| Type | Standalone | Sentinel | Cluster |
|---|---|---|---|
| Nodes | 1 | 3+ | 6+ (minimum) |
| High Availability | No | Yes (Failover) | Yes (Failover) |
| Horizontal Scaling | No | No | Yes (Sharding) |
| Complexity | Low | Medium | High |
| Suitable Scale | Dev / Small | Small–Medium | Large |
1. Standalone
Single node. Any failure causes a full service outage.
# docker-compose.yml
services:
redis:
image: redis:7-alpine
ports:
- "6379:6379"
command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
When to use: Development environments, small services where sessions or simple caching are the only use case.
2. Sentinel (Recommended for Small–Medium Scale)
1 Master + N Replicas + 3 Sentinel nodes.
On Master failure, Sentinel automatically promotes a Replica to Master.
[Client] → [3 Sentinel nodes] → [Master]
↓ Replica
# sentinel.conf
sentinel monitor mymaster 192.168.1.10 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000
sentinel parallel-syncs mymaster 1
Spring Boot Connection:
spring:
data:
redis:
sentinel:
master: mymaster
nodes:
- 192.168.1.1:26379
- 192.168.1.2:26379
- 192.168.1.3:26379
password: your-password
3. Cluster (Large Scale / Horizontal Scaling)
Data distributed across 16384 hash slots. Minimum: 3 Masters + 3 Replicas = 6 nodes.
Slots 0–5460 → Master1 (+ Replica1)
Slots 5461–10922 → Master2 (+ Replica2)
Slots 10923–16383 → Master3 (+ Replica3)
# Create cluster
redis-cli --cluster create \
192.168.1.1:6379 192.168.1.2:6379 192.168.1.3:6379 \
192.168.1.4:6379 192.168.1.5:6379 192.168.1.6:6379 \
--cluster-replicas 1
Note: Multi-key commands (MGET, MSET, etc.) only work when all keys are on the same slot.
Solution: Use Hash Tags → {user:1}:profile, {user:1}:session
Memory Eviction Policy
# maxmemory-policy options
allkeys-lru # Evict least recently used keys (best for caching)
volatile-lru # Evict only keys with TTL, by LRU
allkeys-lfu # Redis 4.0+ LFU algorithm
noeviction # No eviction — return write error (session store)
Data Persistence
# RDB (snapshot) — performance-first
save 900 1 # Save if 1+ key changed in 900 seconds
save 300 10
save 60 10000
# AOF (write-ahead log) — durability-first
appendonly yes
appendfsync everysec # fsync every second (balanced)
Essential Monitoring Metrics
# Real-time stats
redis-cli info stats | grep -E "instantaneous|ops_per_sec|rejected"
# Memory usage
redis-cli info memory | grep -E "used_memory_human|maxmemory_human"
# Slow log (commands over 10ms)
redis-cli slowlog get 10
Architecture Selection Guide
- DAU < 10K: Standalone
- DAU 10K–1M: Sentinel (Master 1 + Replica 2)
- DAU > 1M or data > 100GB: Cluster
- Session store: Sentinel +
noeviction - Cache layer: Standalone or Cluster +
allkeys-lru