Nginx (10)--process model and working principle

Source: Internet
Author: User

1.nginx Process Model

Nginx is a master and worker model. Master is mainly used to manage worker processes, master is compared to the boss, the worker is a wage earners, master command workers to do things. Is the Nginx process model:

Master process:

1. Receive external signals, for example: Kill-quit,kill-hup

Kill-hup Reload the configuration file, and then restart the new worker process, the old is still running, while the old worker process sends the retirement command, the old worker process finishes the original request, retires, does not receive new requests, self-destruct, The new worker process processes the new request.

2. Sending signals to individual worker processes

3. Monitor worker Processes

4. When the worker process exits abnormally, a new worker process is started automatically.

Woker Process:

Handling requests from clients

Receiving the client's connection, completing the data interaction between the server and the backend, the processes between the workers are independent and equal, and the processing opportunities for the requests are equal.

2.nginx Working principle

When the maste process starts, it creates a listener socket listener and then fork out multiple worker processes (depending on the profile), and when a request arrives, The worker process uses a shared lock to ensure that only one worker process is working on the same connection at the same time, and when the worker process receives the request, it begins to do the data response and processing, which process grabs the lock and which process requests.

Nginx is a shell, composed of the kernel and modules, mainly core, basic, third-party modules. Among them, the Core module: HTTP module, event module, mail module.

Nginx (10)--process model and working principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.