All scenes
Build Redis
10 scenes · ~70 min · build the primitive
Build your own Redis
An in-memory data-structure server: one thread, rich types, optional persistence, async replication. Internalize the cost of single-threaded simplicity and a dozen caching/HA decisions get easier.
- 01Foundations — what Redis is, words you'll hearAn in-memory data-structure server, the eight core nouns, and the six canonical types. Orientation before you touch the internals.~7 min
- 02One thread, one command at a timeWhy a single event loop is fast — and why one slow command (KEYS *, big LRANGE, slow Lua) stalls every client.~7 min
- 03Encodings flip under youListpack ↔ hashtable, intset ↔ hashtable, embstr ↔ raw — crossing a threshold silently rewrites memory and op-cost.~7 min
- 04Persistence — fork, CoW, and the 1-second windowRDB snapshots via fork+CoW, AOF fsync policies, and why default Redis can lose ~1s of writes on crash.~7 min
- 05Eviction is sampled, not exactmaxmemory + sampled LRU/LFU — Redis only inspects N keys per pass; tunable via `maxmemory-samples`.~7 min
- 05aTTL and cleanup — lazy, active, and the freer threadPassive + 10Hz active sampler expire keys; DEL of a big value freezes the loop unless `lazyfree-*`/UNLINK offloads to the background freer thread. Cache stampede + jitter / SET NX rebuilder lock.~7 min
- 06Replication is async — acked writes can vanishPSYNC, replication backlog, and the AP-not-CP gotcha: WAIT doesn't fix it; min-replicas-to-write does (at the cost of unavailability).~7 min
- 07Sentinel — quorum detects, majority electsSDOWN/ODOWN ladder, epoch-based election, and the operator footgun: quorum ≠ majority.~7 min
- 08Cluster — 16384 slots and the client routesCRC16 mod 16384, MOVED vs ASK (permanent vs transient), hash tags, configEpoch — and why sharding alone is not HA.~7 min
- 09Design your Redis deploymentCapstone: pick persistence, HA, and sharding for a stated SLO; the verifier traces each choice back to the scene that taught it.~7 min