In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail about redis single-thread high efficiency method, Xiaobian think it is quite practical, so share it for everyone to make a reference, I hope you can gain something after reading this article.
Redis uses a memory-based key/value database using a single-process single-thread model, written in C language, and the official data provided can reach 100000+ QPS (queries per second). So why is Redis so fast? So efficient?
1.Completely memory-based, most requests are pure memory operations, very fast. The data is stored in memory, similar to HashMap, the advantage of HashMap is that the time complexity of lookup and operation is O(1);
2, the data structure is simple, the data operation is also simple, the data structure in Redis is specially designed;
3. Single thread is adopted to avoid unnecessary context switching and competition conditions, and there is no multi-process or multi-thread switching that consumes CPU. There is no need to consider various lock problems. There is no lock release operation. There is no performance consumption caused by possible deadlock.
4. Use multi-channel I/O multiplexing model, non-blocking IO;
5, the use of different underlying models, the underlying implementation between them and the application protocol between the communication with the client is not the same, Redis directly built its own VM mechanism, because the general system calls system functions, it will waste a certain amount of time to move and request;
The above points are relatively easy to understand, below we have a simple discussion of the multiplexing model for multiple I/O:
Multi-channel I/O multiplexing model is the ability to monitor I/O events of multiple streams at the same time by using select, poll and epoll. When idle, the current thread will be blocked. When one or more streams have I/O events, it will wake up from the blocking state, so the program will poll all streams (epoll is only those streams that actually issue events), and only process the ready streams in sequence. This approach avoids a lot of useless operations.
Here "multiplexing" refers to multiple network connections, and "multiplexing" refers to multiplexing the same thread. The use of multi-channel I/O multiplexing technology allows a single thread to efficiently process multiple connection requests (minimizing the time consumption of network IO), and Redis operates very fast in memory, that is, the operation in memory will not become a bottleneck affecting Redis performance, mainly due to the above points Redis has a high throughput.
About redis single thread high efficiency method to share here, hope the above content can have some help to everyone, can learn more knowledge. If you think the article is good, you can share it so that more people can see 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: 208
*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.