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.
- 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.
- 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.
- Login to WHM, click Software —> MultiPHP Manager menu item on the left side.
- Click the System PHP-FPM Configuration tab on page right side.
- 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 ).
- 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.
- But you can also restart the PHP-FPM service through the menu WHM —> Restart Services —> PHP-FPM service for Apache.
- 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.
- 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.
- Click WHM —> Service Configuration —> Apache Configuration menu item on the WHM manager dashboard left side.
- Click the Global Configuration link on page right side.
- 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.
- Click the Save button on the page bottom to save the settings.
- 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.
- Create a new WordPress website, and install all the plugins and themes that the old WordPress website use.
- And monitor the error through WHM —> Server Status —> Daily Process Log.
- 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.
- Click Software —> MultiPHP Manager menu item.
- Click the PHP Versions tab on the page right side.
- 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.
- 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.
- 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.
- If the error still exists after all the above actions, you should buy more CPU resources from your service provider.