Build Redis (10 scenes)
Scene 09 · Design your Redis deployment
Capstone: pick persistence, HA, and sharding for a stated SLO; the verifier traces each choice back to the scene that taught it.
Previously

You've seen every knob — single thread, encodings, persistence, eviction, TTL, replication, Sentinel, Cluster. Time to assemble them for a real workload, and watch the warning chips light up when your choices contradict each other.

Scene 09
Design your Redis deployment
Diagram
A budget canvas: pick instance count, memory per instance, persistence policy, and replication mode from the controls on the left. The center renders the resulting topology — masters, replicas, sentinels, slot fan-out. The right side lights up warning chips whenever your choices contradict each other (e.g. AOF=always with 200k writes/s, or cluster + multi-key transactions without hash-tag).
Session cache · 50k QPS
User sessions, p99 < 1 ms, ok to lose ~1s of writes on crash. Cache, not source-of-truth — clients re-login.
LATENCYp99 < 1 msDURABILITY1s-loss okTHROUGHPUT50k QPS
DEPLOYMENTsingle · master + replicasmasterMASTERRDBAOF·1sreplica 1REPLICARDBAOF·1sKNOBSPERSISTENCERDB + AOF·1sREPLICATIONmaster + 1 replicaHAnoneSAFETYmrw: 0 (off)TRADE-OFFSThroughput2/5Durability3/5Complexity1/5WARNINGSConfiguration matches the SLO — knobs are honest about thetrade-off
Three workloads, three honest configurations. Watch the verifier nod (or refuse) as each SLO drops in and the knobs snap to the deployment that fits it. The captions name the trade — read each one.
Implementation
redis.conf — persistence
fsync policy + RDB snapshot rule
1appendonly yes
2appendfsync everysec # ~1s loss on crash
3appendfsync always # zero-loss; fsync per write
4appendfsync no # OS decides; seconds of loss
5
6save 3600 1 # RDB rule (hour, 1 change)
7save 300 100 # RDB rule (5m, 100 changes)
8no-appendfsync-on-rewrite no
9aof-use-rdb-preamble yes # multi-part AOF (7.0+)
10
11# stop-writes-on-bgsave-error yes
redis.conf — replication & safety
replica wiring + write-refusal floor
1replicaof <MASTER> 6379 # only on replica nodes
2replica-read-only yes
3
4min-replicas-to-write 0 # default: async, best-effort
5min-replicas-to-write 1 # refuse writes if <1 in sync
6min-replicas-to-write 2 # refuse writes if <2 in sync
7min-replicas-max-lag 10
8
9repl-backlog-size 64mb # PSYNC2 partial-resync window
10repl-diskless-sync yes
11
12# masterauth <SECRET>