How to calculate the pm.max_children configuration value of PHP-FPM?

WBOY
Release: 2016-07-06 13:53:03
Original
2699 people have browsed it

<code>pm = static
pm.max_children = 500
</code>
Copy after login
Copy after login

https://segmentfault.com/a/1190000002488698 This article says:pm.max_children 数量的多少根据机器内存确定,基本上一个进程需要30M的内存,假设起100个进程,那么就是3000M,3G内存

A process here requires 30M of memory. How was it calculated?
What is the reasonable basis for calculating the pm.max_children configuration value?

Reply content:

<code>pm = static
pm.max_children = 500
</code>
Copy after login
Copy after login

https://segmentfault.com/a/1190000002488698 This article says:pm.max_children 数量的多少根据机器内存确定,基本上一个进程需要30M的内存,假设起100个进程,那么就是3000M,3G内存

A process here requires 30M of memory. How was it calculated?
What is the reasonable basis for calculating the pm.max_children configuration value?

30M of memory is run out. Take the production machine and run it, it is usually around 10-30M. Look at the res and shr of top
In addition to memory, it also depends on the machine CPU, the number of visits, etc.

For example, if there are 100 requests per second, it is best to open a little more than 100, so that it is neither idle nor waiting.

How much memory does a php process occupy? It is about 20MB (specifically, it depends on how many modules your php has loaded). You can use the pmap command to see where memory is occupied. Therefore, try not to load unnecessary PHP extension modules to reduce unnecessary memory waste.

<code>pmap $(pgrep php-fpm | head -1)</code>
Copy after login

The consumption of a single PHP process is different. When testing your PHP program, you can use the memory_get_peak_usage(true) function to obtain the memory peak value as the program memory consumption of a single request, and take PHP- The basic memory consumption of fpm itself can be used to obtain an approximate memory consumption of a single process.

http://blog.tanteng.me/2016/03/php-fpm-conf/
Please refer to this article

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template