SteelReed

Search

Search posts, questions…

Caching & RedisQuestion 8 / 24

Junior

Why is Redis fast despite being single-threaded, and is Redis 6+ still single-threaded?

Short answer

Redis is fast because the data lives in RAM, its data structures are optimized, and one event loop (epoll) serves thousands of connections with no locks or context switches. Since Redis 6 socket I/O can be multi-threaded, but commands still run one by one on a single main thread.

heavy workThousands of connectionsI/O threads, Redis 6+One thread runs commandsData in RAMBackground: lazy free,BGSAVE

3 points to say:

  1. A command takes microseconds, a network round trip 0.1–1 ms: the network is the bottleneck, and one instance easily reaches 100K+ ops/second.
  2. Each command is atomic, but a GET → compute in the app → SET sequence is not: use DECR, Lua or WATCH/MULTI.
  3. One slow command blocks everyone (KEYS *, DEL on a big key): use UNLINK and lazy free.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.