Why is redis called a single-threaded model
This article will explain in detail why redis is called a single-threaded model. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Redis internally uses the file event handler file event handler, which is single-threaded, so redis is called a single-threaded model. It uses IO multiplexing mechanism to monitor multiple socket at the same time, and selects the corresponding event handler to process according to the events on the socket.
The structure of the file event handler consists of four parts:
Multiple socket
IO multiplexing program
File event dispatcher
Event handler (connection reply processor, command request processor, command reply processor)
Multiple socket may produce different operations concurrently, and each operation corresponds to a different file event, but the IO multiplexer listens to multiple socket and queues the events generated by socket. The event dispatcher takes one event from the queue at a time and hands it to the corresponding event handler for processing.
This is the end of this article on why redis is called a single-threaded model. I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.