Mysql-check whether nginx and php-fpm run in multi-process and multi-thread mode

Source: Internet
Author: User
In the Nginx configuration file, you can set how many nginx processes are enabled, as follows: worker_processes2; you can also set the maximum number of connections for each process, as shown below: worker_connections1024; php-fpm in the configuration file of php-fpm, you can set how many p...

Nginx

In the nginx configuration file, you can set how many nginx processes are enabled, as shown below:

Worker_processes 2;

You can also set the maximum number of connections for each process as follows:

Worker_connections 1024;

Php-fpm

In the php-fpm configuration file, you can set how many php-fpm processes are enabled, as shown below:

Pm. max_children = 5

You can also set the maximum number of connections for each process as follows:

Pm. max_requests = 500

Doubt

From the perspective of nginx configuration and php-fpm configuration, multiple processes can be enabled, and each process can process multiple connections,

My understanding is:Both nginx and php-fpm run in multi-process and multi-thread mode.;

I don't know if I understand this, do I?

Reply content:

Nginx

In the nginx configuration file, you can set how many nginx processes are enabled, as shown below:

Worker_processes 2;

You can also set the maximum number of connections for each process as follows:

Worker_connections 1024;

Php-fpm

In the php-fpm configuration file, you can set how many php-fpm processes are enabled, as shown below:

Pm. max_children = 5

You can also set the maximum number of connections for each process as follows:

Pm. max_requests = 500

Doubt

From the perspective of nginx configuration and php-fpm configuration, multiple processes can be enabled, and each process can process multiple connections,

My understanding is:Both nginx and php-fpm run in multi-process and multi-thread mode.;

I don't know if I understand this, do I?

This problem is relatively preliminary, and the official documents are full of materials.

Nginx isNon-blocking IO & IO multiplexingModel. The epoll-like function provided by the operating system can process requests from multiple clients in one thread.
Nginx processes are threads, that is, each process has only one thread, but this thread can serve multiple clients.

PHP-FPM is a blocking single-threaded model,pm.max_childrenSpecifies the maximum number of processes,pm.max_requestsSpecify the number of requests processed by each process and then restart (because PHP occasionally has memory leakage, You need to restart ).
Each process of the PHP-FPM has only one thread, but one process can only serve one client at the same time.

Most Linux programs tend to use processes rather than threads, because in Linux, the overhead for creating processes is relatively small, and the Linux thread function is not very powerful.

Related Article

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.