Setting a cronjob to reset PHP-FPM

Operating System & Version
CentOS 7
cPanel & WHM Version
90.0.5

WebHostPro

Well-Known Member
PartnerNOC
Jul 28, 2002
1,721
27
328
LA, Costa RIca
cPanel Access Level
Root Administrator
Twitter
Our shared servers seem to gradually build up CPU use until we reset PHP-FPM. It then comes down right away.

I was thinking of running a weekly or maybe even a daily cronjob to reset it.

Do you think this could have any negative precautions?

And what would be the best cron job to do this say daily for example?
 

sparek-3

Well-Known Member
Aug 10, 2002
1,983
218
343
cPanel Access Level
Root Administrator
Probably a better approach would be to figure out what is cause the high CPU usage of php-fpm.

Is it one particular account? Is that account being flooded with PHP requests? Perhaps opcache is misconfigured? Hard to really say.

But if you're resorting to periodically restarting services, that's generally not a great solution because it means you're just masking the underlying issue.
 
  • Like
Reactions: WebHostPro

WebHostPro

Well-Known Member
PartnerNOC
Jul 28, 2002
1,721
27
328
LA, Costa RIca
cPanel Access Level
Root Administrator
Twitter
Thanks, I was thinking that too. It just seems odd that resetting FPM lowers the load so much each time on multiple servers. I can't see anything else obvious that might be related. So I was thinking FPM just gets bloated.

I'll check opcache. Do you have any suggestions for configuring opcache?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,297
1,251
313
Houston
Well there is a known issue with php-fpm and opcache and there has been for a long time though it's not necessarily the fault of opcache. That could be the cause of the issue you're seeing though without more information I couldn't tell you for sure. The PHP bug is here: PHP :: Bug #74709 :: PHP-FPM process eating 100% CPU attempting to use kill_all_lockers


There have been a couple of forums threads on it but the one I remember the most is the following:



As far as restarting php-fpm, it's not an ideal solution, the best solution would be as @sparek-3 suggests but to restart the service it's /scripts/restartsrv_apache_php_fpm