Redis is single-threaded

Redis is, mostly, a single-threaded server from the POV of commands execution (actually modern versions of Redis use threads for different things). It is not designed to benefit from multiple CPU cores.

Everything between the MULTI and EXEC commands is supposed to be atomic, i.e. a transaction. Redis promises that no other client will be served while it is processing this multi-command transaction. If Redis was a multithreaded TCP server, it would have to block requests on all other sockets while doing so. The fact that it's not multithreaded makes it really easy to implement transactions, without the complexity and overhead of managing and synchronizing multiple threads.

The point is: think twice before making your server multithreaded. Is it really needed? Can it actually be detrimental for your architecture's manageability if you decide to make it so?

Jawad Ahmad

Engineering student. Embedded software developer. Expert Dota 2 player (not really). Local swimming champ. 👻

Read More