The single-threaded event loop, data structure encodings, persistence, and master–replica replication.
What Is Redis — An in-memory data-structure server: fast because RAM, expressive because of its types, shared because it is a separate process, and not a system of record because durability and replication are both asynchronous. (6 min read)
Single-Threaded Execution — One thread, no locks, one event loop: a GET takes microseconds, and one KEYS * on 50M keys freezes the server for seconds and can cascade into a failover. (8 min read)
Memory and the Allocator — Why a 5-byte value costs about 88 bytes: the hash table entry, key string, value wrapper, value string and jemalloc rounding, and what eviction and fragmentation do with that. (5 min read)
Persistence: RDB and AOF — RDB snapshots with fork() and copy-on-write recover fast but can lose minutes; the AOF command log loses at most a second; production runs both. (5 min read)
Replication — One master streams every write to read-only replicas without waiting for them: the handshake, full vs. partial resync, the replication backlog, and why WAIT does not make writes durable. (11 min read)
Redis Cluster — Data sharded across 16,384 hash slots with gossip and no central coordinator, MOVED and ASK redirects, and why an acknowledged write can still be lost in a failover. (12 min read)
High Availability and Streams — Sentinel automates failover for a single shard, but Sentinel and Cluster agree on topology, not data, so both can lose acknowledged writes; plus how Redis Streams and consumer groups work. (8 min read)
Why Redis for Rate Limiting — What a rate limiter decides on every request, and why Redis's atomic counters, TTLs and sub-millisecond latency make it the natural place to keep the counts. (3 min read)
Fixed Window Counter — The simplest limiter, INCR plus EXPIRE per window, and its bug: a caller straddling the window boundary can send twice the limit. (2 min read)
Sliding Window Log — A sorted set of request timestamps fixes the boundary burst exactly, at the cost of remembering every request: O(N) memory per caller. (3 min read)
Sliding Window Counter — Weighting the previous window's count gets about 99.997% of the log's accuracy from two numbers instead of thousands of timestamps. (5 min read)
Token Bucket — Controlled bursting: quiet callers bank tokens and spend them in a burst, which is why Stripe, GitHub and AWS use it, implemented with lazy refill in one Lua script. (3 min read)
Leaky Bucket (GCRA) — A constant output rate instead of bursts, and GCRA, which implements it with a single stored timestamp per caller. (2 min read)
Lua Scripts and Atomicity — Why read-check-write limiters need a Lua script to be atomic on single-threaded Redis, and what EVALSHA, key declarations and script time limits imply. (2 min read)
Distributed Rate Limiting — Limiting across many app servers and Redis shards: hash tags to keep a caller's keys together, local pre-limiting, and the accuracy you give up for latency. (2 min read)
Telnet and Raw Sockets — Telnet is just a TCP socket and a terminal; it works on Redis because RESP is plain text you can type, and in Go it is net.Dial("tcp", ...). (2 min read)
RESP Typed Responses: RESP2 vs. RESP3 — RESP3 lets the server say what kind of value it is sending (map, double, boolean, push), so client libraries return native types instead of guessing from raw bytes. (2 min read)
Transactions vs. Failover — How a failover can keep the debit and lose the credit of an "atomic" MULTI/EXEC: atomic execution and atomic durability are different promises, and Redis makes only the first. (3 min read)
Master-to-Replica Sync in Go — A runnable Go sketch of the replication wire protocol: RESP byte counting, the PING/REPLCONF/PSYNC handshake, full vs. partial resync, and the replica's live stream and ACK loop. (4 min read)
Replication Backlog and Per-Replica Offsets in Go — A Go sketch of repl_backlog as a circular buffer with per-replica ACK offsets and WAIT, ending in a demo where wraparound forces a full resync. (3 min read)
Synthesis and Self-Test — Where one mechanism's guarantee is paid for by another's cost, then questions that each need two or more parts of the guide to answer. (9 min read)