25 Nov, 2026Akshit Mandial
What makes Redis So Fast?
At Monk CI, we use Redis where requests arrive very quickly. Redis runs most commands on one main thread. So why don't requests queue up and slow down?
How the Redis event loop works
Redis uses an event loop and does not create a thread for each connection. The operating system tells Redis when a socket is ready. Redis reads the request, runs the command, sends the response and moves to the next event.
Thousands of clients can connect at the same time, but their commands pass through one ordered lane. Concurrency is not the same as parallel execution.
Modern Redis can use extra threads for parts of network I/O. Command execution still follows one ordered stream.
Why small commands keep Redis fast
Commands such as `GET`, `SET`, `INCR` and small hash or set lookups need very little work. The data is in memory, so Redis does not wait for disk. Commands do not compete across worker threads, so Redis also avoids most locking overhead.
RAM explains a big part of the speed, but not all of it. Efficient data structures and event-driven networking also help. The design assumes that each command finishes quickly.
Pipelining does not run commands in parallel. It lets the client send many commands without a network round trip after each one. The commands still run in order, but less time goes to the network.
How one slow command blocks every client
Picture the lane as a queue of small commands. Each one is quick, so the queue moves. Now add one command:
GET user:1
KEYS *
SET session:42
INCR counterWith millions of keys, `KEYS *` must inspect the whole keyspace. While it runs, every other command waits. One expensive command adds latency for unrelated clients.
Redis commands that block other clients
`KEYS *` is the classic example. To iterate over a large keyspace, use `SCAN`. It splits the work into many small calls.
The same applies to any command that reads or returns a large collection. `HGETALL` on a hash with hundreds of thousands of fields is not cheap. Also check:
- `SMEMBERS` on a huge set
- `LRANGE 0 -1` on a very large list
- large `SUNION` or `SINTER` operations
- expensive `SORT` operations
- long-running Lua scripts or Redis Functions
- synchronous operations on very large values
Cost depends on data size. Even an O(1) key lookup can be slow. Redis finds the key quickly, but it must still copy the value and send it to the client. With a large value, that takes time.