How to observe PHP-fpm max worker error

When you receive PHP-FPM error from your website. There are one setting that you need to take care.
- Check the domain PHP setting

How to check the setting?
- From SSH or WHM.

WHM:
1. Login to WHM, access to MultiPHP Manager > User Domain Settings (select the domain)
2. Refer to the below PHP-FPM setting. This VPS server has 12 GB memory.


3. Let us adjus the PHP-FPM setting.
- the following command will help us to determine the memory used by each (PHP-FPM) child process:
'ps -ylC php-fpm --sort:rss'

The RSS column shows non-swapped physical memory usage by PHP-FPM processes in kilo Bytes.
=============
S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
S 1001 31501 24852 9 80 0 123200 136556 skb_wa ? 00:00:50 php-fpm
=============

On an average each PHP-FPM process took ~123MB of RAM on my machine.

pm_max_children = Total RAM dedicated to the web server / Max child process size - in this sample case it was 100MB.

This VPS server has 12GB of RAM, so:
pm_sever_children = 10240 MB / 130 MB = 79

I left some memory for the system to breath. You need to take into account any other services running on the machine while calculating memory usage.

So, in this example, we can change the Max Children to 79. Other setting remain no change.

Please note that very high values does not mean necessarily anything good.

You can check an average memory usage by single PHP-FPM process with this handy command:
==========
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'
==========

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.