| Network I/O Model |
Multi-threaded non-blocking I/O built on libevent: a main listener thread accepts sockets and hands descriptors via pipes to worker threads. Uses multiple CPU cores well, but introduces cache-coherency traffic and global lock contention (e.g. shared locks for global stats counters). |
Single-threaded I/O multiplexing via its lightweight ae event loop (epoll, kqueue, select). Zero lock overhead makes fast I/O commands fly—but heavy CPU commands (SORT, huge SUNION, KEYS *) stall all other requests. (Redis 6+ added optional I/O threads for socket reads/writes while keeping command execution single-threaded.) |
| Memory Management |
Pre-allocated slab / chunk memory pool. Eliminates malloc/free overhead and limits fragmentation, but wastes internal slack inside chunks and can trigger per-slab evictions even while other slab classes still have free memory. |
Allocates memory on demand (jemalloc), trading some fragmentation for flexible sizing. Tracks keys with TTL separately in an expires dict; persistent keys are never evicted under noeviction (and only eligible keys are evicted under volatile-* policies). |
| Data Consistency |
Provides built-in CAS (Check-And-Set) for optimistic lock-free concurrency control on individual keys. |
No standalone CAS command, but supports MULTI / EXEC transactions (atomic command batches uninterrupted by other clients), optimistic locking via WATCH, and atomic server-side Lua scripts. |
| Data Types & Operations |
Simple key-value strings only; no key enumeration, no persistence and no built-in replication. |
Rich native types (String, List, Hash, Set, Sorted Set…), RDB/AOF persistence, primary-replica replication, Sentinel HA and Cluster sharding. Never run KEYS * in production—use incremental SCAN or inspect offline RDB dumps. |