In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "Redis single-threaded reactor model is how", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Redis single-threaded reactor model is how" it!
High performance of redis
Pure memory access, all data are in memory, all operations are memory-level operations, memory response time is nanosecond level. Therefore, the cpu of redis process basically does not have the problems of disk I _ max O waiting time and memory read and write performance, and CPU is not the bottleneck of redis (memory size and network I _ max O are the bottleneck of redis, that is, the network transmission delay between client and server). [related recommendation: Redis video tutorial]
Using single-thread model, single-thread implementation is simple. Avoids frequent context switching by multithreads and the overhead caused by synchronization mechanisms such as locks
Simple and efficient basic data structures: dynamic strings (SDS), linked lists, dictionaries, jump linked lists, integer sets and compressed lists. Then redis implements the objects that users can manipulate on this basis: strings, lists, hashes, collections, ordered collections, etc.
Network event handler for reactor mode. It uses Imax O multiplexing to monitor multiple sockets at the same time, which is an efficient Icano model. Reactor related knowledge can take a look at the framework of this article: take a look at the linux high-performance network IO+Reactor model
Why use single thread
Single thread is adopted to avoid unnecessary context switching and competition conditions, and there is no CPU consumption caused by multi-thread switching.
There is no need to consider the problems of various locks, there are no locking and releasing operations, and there is no performance consumption caused by possible deadlocks
Simple and maintainable, multithreaded mode will make the programming more complex and troublesome, and single-threaded implementation is easy to implement.
Is redis a single threaded system?
We often say that redis single thread refers to its network event handling model reactor is single thread
If a client request removes millions of keys values, this command may cause blocking. Multithreading is selected in redis 4.0to implement this kind of non-blocking commands.
In the redis6.0 version, multithreading is formally introduced to deal with the client's Imax O read and write response, while the handling of redis command events is still handled in the main thread.
If it is for the entire redis system, there are always other threads to handle asynchronous tasks, such as the synchronization of AOF and RDB
Redis I-paw O model
Redis processing is fast, not only because it is a single-threaded pure memory system, but also because it adopts Reactor model and uses IWeiO multiplexing to process external requests and reduce network connection and read-write waiting time. It can concurrently process a large number of client requests in the network Istroke O operation, and achieve high throughput and high concurrency.
The multi-threaded version of redis, Istroke O model 6.0.
Thank you for your reading, the above is the "Redis single-threaded reactor model is how" the content, after the study of this article, I believe you on the Redis single-threaded reactor model is how this problem has a deeper understanding, the specific use of the need for you to practice verification. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.