PHP-FPM causing server to crash with massive CPU spikes on very small WordPress websites

whew…that’s what i though about the separate pool for each one…i mid read things…:slight_smile:

1 Like

That’s amazing @Dibs great work on finding these issues. I’ve now moved Snagging Company to its own server with a new hosting company I have found to be great value running AlmaLinux 8.6 with PHP 8 (settings below), which is absolutely flying now!..but it’s a 6vCPU VPS with 24GB of memory (for £28+VAT, that isn’t bad for this client as for my SEO work the speed is critical), so massive power for 1x WordPress website running WooCommerce, but still spiking and using all resources, so I will take a look at your recommendations above! If they work, I can move a few of my production sites over to this server as well!

pm = dynamic
pm.max_children = 20
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 5
php_value[max_execution_time] = 300
php_admin_value[memory_limit] = 256M
php_admin_value[post_max_size] = 64M
php_admin_value[upload_max_filesize] = 64M
php_admin_value[max_input_time] = 120
php_value[file_uploads] = On

Sorry for going quiet for so long and for showing a very lazy workaround that didn’t exactly resolve the issue.

@Dibs, would you mind breaking down your fix a bit more for me? I renamed www.conf to www.conf.template on a test server, but that crashed everything when I restarted php-fpm. My production server is still getting smashed by excessive resource usage, which has caused a couple more minor site outages.

@dougtracey - I went into all the numeric pool files and wrote down a little table (columns being)

  • Pool File Name (the numeric number)
  • User (in numeric pool file)
  • Group (in numeric pool file)
  • Port (in numeric pool file)
  • Apache Port(left this blank for now).

Then went into /etc/apache2/sites-available and looked in each conf file and looked for the line that said:

SetHandler proxy:fcgi://localhost:8002 or whatever port number is in use and filled in the “Apache Port” in my table.

This was just to make sure that everything matched and all the Virtual Servers (are\were) using php-fpm, had unique ports (which they should) and had a matching port number set in each Apache conf file.

Once confirmed (that no Virtual Server was using the www.conf file & had it’s own numeric pool file) - it was just a simple case of renaming www.conf to www.conf.template using a mv command.

In a nutshell - all my virtual servers are using a unique port and yet I was seeing an entry in top for php-fpm for a user www-data (which shouldn’t have been there) and tracked it down to a line in etc/php/php7.4/fpm/php-fpm.conf

include=/etc/php/7.4/fpm/pool.d/*.conf

i.e. it was firing up a pool for a “config” that was a leftover from the default php-fpm setup\install - where every everything runs under one user\pool (www-data or something) but multiple processes obviously.

Hope it makes sense.

Dibs

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.