In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Why does redis use single thread? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Does not require the performance consumption of various locks
The data structures of Redis are not all simple Key-Value, but also complex structures such as list,hash, which may perform very fine-grained operations, such as adding an element after a long list and adding or deleting an object in the hash. These operations may require a lot of locks, resulting in a significant increase in synchronization overhead.
In short, in the case of a single thread, there is no need to consider all kinds of locks, there is no lock release operation, and there is no performance consumption caused by possible deadlocks.
Single-thread multi-process cluster scheme
The power of single thread is actually very powerful, and the efficiency of each core is also very high, so multi-thread can naturally have a higher performance limit than single-thread, but in today's computing environment, even the upper limit of single-machine multi-thread can not meet the needs. What needs to be further explored is the scheme of multi-server clustering, and the technology of multi-thread in these schemes is still useless.
Therefore, single-threaded, multi-process cluster is a fashionable solution.
CPU consumption
The use of single thread avoids unnecessary context switching and competition conditions, and there is no CPU consumption caused by multi-process or multi-thread switching.
But what if CPU becomes a Redis bottleneck, or you don't want to leave the other CUP cores of the server idle?
You can consider several Redis processes. Redis is a key-value database, not a relational database, and there are no constraints between the data. As long as the client can tell which key is on which Redis process.
This is the answer to the question about why redis uses single thread. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.