Nginx concurrent processing mechanism

I. Introduction

Concurrent processing mechanism under normal circumstances there are three types: multi-process, multi-threaded, asynchronous mechanism. Nginx for concurrent processing while using three mechanisms. Of course, its asynchronous mechanism using asynchronous non-blocking mode.
            We know Nginx processes fall into two categories: master process and worker processes. Each master process can generate multiple worker processes, so it is a multi-process. Each worker process can handle multiple user requests, each user request will be handled by a thread, it is multi-threaded.
So, how to explain the "non-blocking asynchronous" concurrent processing mechanism?
         worker process is used epoll multiplexing mechanism to handle the back-end server. When the backend server returns a result, the back-end server will callback epoll multiplexer notifies the corresponding worker process by the multiplexer. At this point, worker process will suspend transaction currently being processed, IO returns the result to take to respond to client requests. After the response is completed, we will continue the implementation of pending transactions. This process is "asynchronous non-blocking" of.

 

Two, master process

master process is responsible for the life cycle of worker processes, to accept external commands, parse perl scripts.

Three, worker process

worker process of receiving and handling client requests, each user has a thread to handle requests, so it is multi-threaded.

Guess you like

Origin blog.csdn.net/u012965203/article/details/93379635