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.
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.
Single-Threaded Event Loop & CPU Cache Locality
Over 1 million operations per second per standard commodity nodeDelivering predictable sub-millisecond read/write latencies under concurrency without lock contention or thread synchronization overhead.
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.
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.
Explain why Redis is single-threaded for execution: memory access is 100,000x faster than disk, making CPU locks the bottleneck, not raw compute.
Salvatore Sanfilippo (antirez) • 2021
Ready to Practice Redis-Style Systems?
Start with foundational networking, compute, and storage, and build up to complex distributed consensus.