How To Fix WordPress Website PHP-FPM Bottleneck With Child Process

My website runs slowly these days. I use WHM —> Server Status —> Daily Process Log to diagnose the issue and find there are a lot of processes that cost the most CPU percentage to run command php-fpm: pool. This article will tell you how to fix the php-fpm: pool command cost high CPU usage issue.

1.Why There Are So Many Processes Triggered By Command PHP-FPM: Pool.

  1. The reason is not clear why there are so many processes that run the command php-fpm: pool. Maybe because of the WordPress plugin or theme, maybe because the website is under attack, maybe because of the website traffic spike. But the issue does not happen regularly at a special time, it happened occasionally. So I find below methods to fix this issue.

2. Enlarge PHP-FPM Max Children Process Number.

  1. Enlarge php-fpm children process number in the pool can make it process more PHP requests at the same time, then it can improve web server performance. But to use php-fpm service, you should first make sure your VPS machine RAM is equal to or bigger than 2G, otherwise, there will have a performance issue. Below are the steps.
  2. Login to WHM, click Software —> MultiPHP Manager menu item on the left side.
  3. Click the System PHP-FPM Configuration tab on page right side.
  4. On the page right side, input a bigger number ( for example 20 ) in the Max Children text box. Please note, this number can not be so big, it is because if all the processes in the pool are active, then the server load may have issues ( each process will cost some CPU usage, if there are too many processes then the total CPU usage is overloaded, then there are deadlock between processes and total server load ).
  5. Do not forget to click the Save Configuration button on the page bottom to save the changes. And the php-fpm settings change do not need to restart anything.
  6. But you can also restart the PHP-FPM service through the menu WHM —> Restart Services —> PHP-FPM service for Apache.
  7. The above settings will be applied to all the WHM account ( domains ), but you can configure PHP-FPM options settings for each domain separately. We will introduce how to do it in section 5. Disable PHP-FPM Service below.
  8. We will also write another article to tell you the best number to input for PHP-FPM Pool Options on the above page because different traffic value websites need different option values to make it’s performance best.

2. Enlarge Apache Start Server, Min Spare Server, Mac Spare Server Number.

After enlarging php-fpm max children process number, you had better also enlarge Apache start server, min spare server, and max spare server number equal to or bigger than above php-fpm max children process number according to the article Bottleneck with Child Processes.

  1. Click WHM —> Service Configuration —> Apache Configuration menu item on the WHM manager dashboard left side.
  2. Click the Global Configuration link on page right side.
  3. Now scroll down in the popup page and you can change the apache Start Servers, Minimum Spare Servers, and Maximum Spare Servers number in the global configuration settings page.
  4. Click the Save button on the page bottom to save the settings.
  5. Click Rebuild Configuration and Restart Apache button to make the above changes take effect.

3. Find Reason By Deactivate WordPress Plugin Or Change Theme Template.

If the issue still exists after enlarging the apache server and php-fpm pool size. It may be because your installed WordPress plugin or used theme template trigger this issue. You can fix it follow the below steps.

  1. Create a new WordPress website, and install all the plugins and themes that the old WordPress website use.
  2. And monitor the error through WHM —> Server Status —> Daily Process Log.
  3. If the error exists in the new website also, then deactivate WordPress plugins one by one and change the new website theme to monitor the error until the error disappears.

4. Set WordPress WebSite To Debug Mode To Find The Reason.

5. Disable PHP-FPM Service.

  1. Click Software —> MultiPHP Manager menu item.
  2. Click the PHP Versions tab on the page right side.
  3. Click the Turn Off button in the System PHP-FPM section. Then when you create a new WHM CPanel account ( create a new domain ), it will not enable php-fpm service for that domain automatically.
  4. Scroll down the above MultiPHP Manager page to the domain list area. You can see for each domain, there has a toggle button at the end of the domain record to let you turn on/off php-fpm service for the specified domain.
  5. Click the Edit PHP-FPM link behind the above toggle button, you can edit the domain specified PHP-FPM Pool Options, that is to say, each domain can have it’s own php-fpm pool settings.

6. Buy More CPU Resources.

  1. If the error still exists after all the above actions, you should buy more CPU resources from your service provider.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.