• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Struggling to calculate pm.max_children and share between sites

jim.wilson

New Pleskian
Server operating system version
CentOS Linux 7.9.2009 (Core)
Plesk version and microupdate number
Plesk Obsidian
Hi all,

I am struggling to get a happy balance on pm.max_children and am having issues with the server maxing out resources

Following https://support.plesk.com/hc/en-us/articles/360011988053

Here is the results of ps -ylC php-fpm --sort:rss

Capture.PNG

Server: 64Gb, 32 Core

The server runs

a - very busy site (On Dedicated FPM > Apache)
b - average site (On Dedicated FPM > Apache)
c & d - very small sites (On Fast CGI)

Site a regularly has problems with FPM consuming vast CPU & memory


Any thoughts/suggestions on how to balance / resolve issues ?

Thanks
 
There is not really anthing like "balancing" the PHP-FPM processes. If a request comes in, PHP will try to process it. You either provide enough resource for it or new requests cannot be processed.

You'll need to find the root cause in the access_ssl_log of your website. Normally it is bad bots that are causing a high load. Exclude them either by blocking the source IPs or by blocking their bot names, e.g. by .htaccess commands.
 
For troubleshooting purposes I can also recommend enabling the fpm status dashboard.
This often allows for easy identification of abusive PHP requests and also gives a good overview on what is really running at the time.

In order to do so, you need to:

a) add the following lines into "Additional directives" section of the PHP settings for this page
Code:
[php-fpm-pool-settings]
pm.status_path = /fpm-status

b) add the following lines into the additional Apache directives ("Apache & nginx Settings") of your site (replace the DOMAIN.TLD with the domain name of this site)
Code:
<LocationMatch ^/fpm-status>
    SetHandler proxy:unix:/var/www/vhosts/system/DOMAIN.TLD/php-fpm.sock|fcgi://127.0.0.1:9000
</LocationMatch>

After that you can access this status page via the URL: https://DOMAIN.TLD/fpm-status?full&html

If you plan to use this for a longer time, I recommend to "customize/randomize" the fpm-status URL somewhat or limit the access to your IP address or enable username/password authentication.
 
Back
Top