Simple Network IO, the volume to a certain extent, multithreading do have advantages, but not simple multithreaded, but each thread has its own epoll such a model,
That is, multithreading and multiplexing mixing. But. Also consider the Redis operation is in-memory data structure. If you operate in multiple threads, you need to lock these objects.
So using multithreading can improve performance, but the efficiency of each thread is severely reduced, and the logic of the program is seriously complicated. Redis's data structures are not all simple key-value,
There are complex structures, such as list,hash, that are likely to perform fine-grained operations, such as adding an element after a long list, adding or deleting a hash
An object that can also synthesize multi/exec groups. A very large number of locks may be required in such an operation, resulting in a significant increase in synchronization overhead. Redis
After weighing the choice is to use a single thread, highlighting the flexibility of their functions. Any atomic operation on a single thread basis can be implemented almost without cost, and how complex data structures are
Can be easily used, even with features such as LUA scripts. For multiple threads This requires a much higher price.
Not all KV database or memory database should use a single thread, such as zookeeper is multi-threaded, and ultimately to see the author's own will and choice. Single Thread
The power is actually very strong, each core efficiency is also very high, in today's virtualized environment can take full advantage of the cloud environment to improve resource utilization. Multithreading naturally can be compared to single
Thread has a higher performance limit, but in today's computing environment, even the upper limit of multithreading is often unable to meet the needs, the need to further explore the multi-server clustering
Solution, the multithreading technology is still not used in these scenarios, so the single threaded, multi process cluster is a fashionable solution.