In my PHP-FPM configuration I have 3 Pools, the eg: Config is:
;;;;;;;;;;;;;;;;;;;;;;;
; Pool 1 ;
;;;;;;;;;;;;;;;;;;;;;;;
[www1]
user = www
group = www
listen = /tmp/php-fpm1.sock;
listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode = 0666
pm = dynamic
pm.max_children = 40
pm.start_servers = 6
pm.min_spare_servers = 6
pm.max_spare_servers = 12
pm.max_requests = 250
slowlog = /var/log/php/$pool.log.slow
request_slowlog_timeout = 5s
request_terminate_timeout = 120s
rlimit_files = 131072
;;;;;;;;;;;;;;;;;;;;;;;
; Pool 2 ;
;;;;;;;;;;;;;;;;;;;;;;;
[www2]
user = www
group = www
listen = /tmp/php-fpm2.sock;
listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode = 0666
pm = dynamic
pm.max_children = 40
pm.start_servers = 6
pm.min_spare_servers = 6
pm.max_spare_servers = 12
pm.max_requests = 250
slowlog = /var/log/php/$pool.log.slow
request_slowlog_timeout = 5s
request_terminate_timeout = 120s
rlimit_files = 131072
;;;;;;;;;;;;;;;;;;;;;;;
; Pool 3 ;
;;;;;;;;;;;;;;;;;;;;;;;
[www3]
user = www
group = www
listen = /tmp/php-fpm3.sock;
listen.backlog = -1
listen.owner = www
listen.group = www
listen.mode = 0666
pm = dynamic
pm.max_children = 40
pm.start_servers = 6
pm.min_spare_servers = 6
pm.max_spare_servers = 12
pm.max_requests = 250
slowlog = /var/log/php/$pool.log.slow
request_slowlog_timeout = 5s
request_terminate_timeout = 120s
rlimit_files = 131072
I calculated the pm.max_children processes according to some example calculations on the web like 40 x 40 Mb = 1600 Mb
. I have separated 4 GB of RAM for PHP, now according to the calculations 40 Child Processes via one socket, and I have total of 3 sockets in my Nginx and FPM configuration. My doubt is about the amount of memory consumption by those child processes.
I tried to create high load in the server via httperf hog
and siege
but I could not calculate the accurate memory usage by all the PHP processes (other processes like MySQL and Nginx were also running). And all the sockets were in use, So, I seek guidance from anyone who have done this before or know how exactly the pm.max_children in PHP Works.
Since I have 3 Pools/sockets with 40 child processes does that count to 3 x 40 x 40 Mb
of Memory usage ? or it is just like 40 Max. Child processes sharing 3 sockets (and the total memory usage is just 40 x 40 Mb
) ?
40Mb
figure per child?3 x 40 x 40
but cannot confirm for sureps aux | grep php-fpm | awk '{print $2}' | xargs pmap | grep total | awk '{print substr($0, 1, length($0)-1)}' | awk '{print $2}' | awk '{total = total + $1}END{print total}'
- You can divide that number by the number of worker processes to get the average size used by a php-fpm process