StreamHub's Redis cluster holds stream metadata, session tokens, and rate-limit counters for every API pod. When one shard goes hot during a viral stream, the difference between a well-tuned cluster and a naive single-node Redis is the difference between 5 ms and timeout errors.
Redis cluster architecture
Hash ring0 … 2^32-1
Node Akeys 0–25%
Node Bkeys 25–50%
Node Ckeys 50–75%
Node Dkeys 75–100%
New node E joins → only ~1/N keys move, not all keys.
Redis Cluster essentials
- 16384 hash slots partitioned across primary nodes; each key maps to one slot.
- Primary + replica pairs per shard — replica promotes on primary failure.
- Client-side routing: Redis clients follow
MOVED/ASKredirects to the correct shard. - No cross-slot transactions unless keys share the same hash tag
{user}:profileand{user}:settings.
# ElastiCache Redis cluster (pseudo-config)
engine: redis-7
node_type: cache.r7g.xlarge
num_shards: 12
replicas_per_shard: 1
maxmemory_policy: allkeys-lru
cluster_mode: enabled
Eviction policies in practice
| Policy | Behaviour | When to use |
|---|---|---|
| allkeys-lru | Evict any key by LRU when memory full | General cache — StreamHub metadata |
| volatile-lru | Evict only keys with TTL set | Mixed cache + session store |
| allkeys-lfu | Evict least frequently used keys | Stable hot sets (leaderboards) |
| noeviction | Return errors when memory full | Rate limit counters — never silently drop |
allkeys-lru
BehaviourEvict any key by LRU when memory fullWhen to useGeneral cache — StreamHub metadatavolatile-lru
BehaviourEvict only keys with TTL setWhen to useMixed cache + session storeallkeys-lfu
BehaviourEvict least frequently used keysWhen to useStable hot sets (leaderboards)noeviction
BehaviourReturn errors when memory fullWhen to useRate limit counters — never silently drop
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 3 sections
- Hot key problem
- Cache stampede prevention
- Monitoring and operations
Test yourself
Answer these before moving on — recall is what makes it stick.