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 multiplexing
Model. 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_children
Specifies the maximum number of processes,pm.max_requests
Specify 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.