A detailed explanation of two process management modes in ES0en fpm

  • 2020-06-03 06:02:19
  • OfStack

Two process management modes of ES0en-fpm
The number of processes in ES3en-ES4en can also be set to be dynamic or static.
One is to start the specified number of ES6en-ES7en processes directly, without increasing or decreasing;
The other is to start a certain number of ES9en-ES10en processes at the beginning. When the request quantity becomes larger, the number of ES11en-ES12en processes will be dynamically increased to the upper limit, and the number of idle processes will be automatically released to a lower limit.
These two different implementations can be tailored to the actual needs of the server.
Let's start with the parameters involved, pm, pm.max_children, pm.start_servers, pm.min_spare_servers and pm.max_spare_servers.
pm means that in that way, you have a choice of two values, static (static) or dynamic (dynamic).
In older versions, dynamic is known as ES36en-ES37en. Note the instructions given in the configuration file. PHP5. 3
The default static processing mode of php-ES41en causes the process of ES42en-ES43en to consume memory for a long time and cannot be freed. This is also one of the reasons for the error of nginx. Therefore, the processing mode of ES45en-ES46en can be changed to apache mode.
The meanings of the following four parameters are as follows:
pm. max_children: Number of ES53en-ES54en processes started statically.
pm. start_servers: Number of initial ES59en-ES60en processes in dynamic mode.
pm.min_spare_servers: Minimum number of ES66en-ES67en processes in dynamic mode.
pm. max_spare_servers: Maximum number of ES73en-ES74en processes in dynamic mode.
If dm is set to static, then only the parameter pm.es79EN_children takes effect. The system will start setting the number of ES81en-ES82en processes.

If dm is set to dynamic, the pm.es88EN_ES89en parameter fails and the next three parameters take effect. The system will start pm.start_ES94en processes at the beginning of php-ES91en operation, and then adjust the number of ES105en-ES106en processes between ES97en.min_ES99en_ES100en and ES101en.max_ES103en_ES104en dynamically according to the requirements of the system.

So, for our server, which method of execution is better? In fact, like Apache1, the PHP program we ran had more or less a memory leak after execution.

This is also the reason why an ES113en-ES114en process occupies only about 3M memory at the beginning, but rises to 20-30ES116en after running for a period of time. Therefore, the dynamic mode can recycle and free up some memory because it will kill off the redundant process, so it is recommended to use on the server with less memory or VPS. The specific maximum quantity is obtained according to memory /20M. For example, VPS for 512M, pm.max_ES123en_ES124en is recommended as 20. As for ES125en.min_ES127en_ES128en, it is recommended to set it according to the load on the server, with a more appropriate value between 5 and 10.

Then, for servers with large amounts of memory, setting it to static is more efficient. Since frequent switching of php-fpm processes also has a time lag, it is better to turn on static with enough memory. The amount is also available based on memory /30M. For example, a server with 2GB memory can be set to 50. 4GB memory can be set to 100 etc.

Related articles: