In-Memory Datastores & CachingPRODUCTION RETROSPECTIVE

Redis: Single-Threaded Event Loop Physics, Redis Cluster & Sentinel High Availability

How Redis delivers sub-millisecond latencies across millions of operations per second using epoll non-blocking I/O multiplexing, 16,384 hash slots, and Sentinel quorum failover.

High-Level Architectural Overview

Redis operates as an in-memory key-value data structure server. By executing all commands on a single-threaded non-blocking event loop, Redis avoids thread context switching, locks, and race conditions.

Key Engineering Problems & Trade-Offs

Single-Threaded Event Loop & CPU Cache Locality

Over 1 million operations per second per standard commodity node
The Scaling Problem

Delivering predictable sub-millisecond read/write latencies under concurrency without lock contention or thread synchronization overhead.

Engineering Solution

Use Linux epoll/kqueue non-blocking socket multiplexing on a single thread. Data structures are kept entirely in RAM, eliminating disk I/O from the request critical path.

Architectural Trade-Offs

Long-running commands (e.g. KEYS * or slow Lua scripts) block the entire server; operations must maintain O(1) or small O(log N) complexity.

How to Say This in an Interview

Explain why Redis is single-threaded for execution: memory access is 100,000x faster than disk, making CPU locks the bottleneck, not raw compute.

Curriculum Topics Used in Redis Architecture (1)
Full Syllabus
Primary Technical Sources & Published Papers
Redis Internal Design & Hash Slot Routing

Salvatore Sanfilippo (antirez) • 2021

Ready to Practice Redis-Style Systems?

Start with foundational networking, compute, and storage, and build up to complex distributed consensus.

Start Free: Topic #1