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--
Why is redis so fast? I believe that most people do not understand, today the editor in order to let you know more about Golang, to sum up the following content, let's look down together.
Redis adopts KV database based on memory and adopts single-process and single-thread model, which is written by C language. The official data is qps that can reach 1000000 +. This data is no worse than the same memory-based KV database Memcached using single-process multithreading.
The main reasons why Redis is fast are:
1. Completely based on memory
two。 The data structure is simple, and the data operation is also simple.
3. Using multi-channel Ipaw O multiplexing model
The first and second points are not discussed in detail, mainly around the third point of the use of multi-channel Icano multiplexing technology to carry out.
The multiplexing model of multiple streams uses the ability of select, poll, and epoll to monitor multiple streams' Icano events at the same time, blocking the current thread when idle, and waking up from the blocked state when one or more streams have Icano events, so the program polls all streams once (epoll polls only those streams that actually emit events) and only processes ready streams sequentially. This practice avoids a large number of useless operations. Here, "multiplex" refers to multiple network connections, and "multiplexing" refers to the reuse of the same thread. Using multi-channel IO multiplexing technology allows a single thread to process multiple connection requests efficiently (minimizing the time consumption of network Redis), and Redis operates data very fast in memory (the operation in memory will not become the performance bottleneck here). The above two points make Redis have high throughput.
Unlike Memcached, Redis does not use Libevent directly, but completes a very lightweight implementation of common interfaces such as select, epoll, evport, and kqueue. Choose the appropriate interface for different system calls. The default is epoll under linux. Because Libevent is heavier and has a large amount of general code, with a lot of features that Redis does not need, Redis chose to package a set of its own in order to pursue "lightweight" and remove dependence.
Benefits of single process and single thread
1. The code is clearer and the processing logic is simpler.
two。 There is no need to consider the various locks, there is no lock release lock operation, and there is no performance consumption due to the possibility of deadlocks.
3. There is no switching caused by multi-process or multi-thread that consumes CPU.
These are the details of the main reasons why redis is fast. Do you have anything to gain after reading it? If you want to know more about it, you are welcome to follow the industry information!
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.