I am getting constantly high and wildly fluctuating CPU usage % for php-cgi commands as seen via "top" on my Centos server..
I have a server density account and it seems that this is a common trend:
User - PID - CPU % - MEM % - VSZ - RSS - TT - Stat - Started - Time - Command
500 - 6389 - 22.4 - 3 - 271136 - 32380 - ? - S - 20:26 - 0:40 - /usr/bin/php-cgi
Seems there are about 6 or so of those records in my processes list at any given check-in.
Any ideas what's causing this? I have fast_cgi installed and the module is loading.. Not sure why it isn't handling this though.
Any help would be greatly appreciated!
Ryan
php-cgi is responsible for actually running all your code. It's very normal to see these taking up resources all the time. If you're not seeing additional traffic to your website, this may be an indication that you have gotten hacked (people sending large amounts of spam or DDoS attacks via a compromised webserver will use lots of CPU).
I would suggest you stop using php-cgi and switch over to PHP-FPM. This would give you better visibility into what exactly is going on. It can also make things more efficient, as PHP-FPM workers can share one instance of an APC cache, while this may not be the case depending on how your php-cgi installation is configured. PHP-FPM also lets you enable the 'slow log', which captures a snapshot of what exactly is executing whenever a request takes longer then X seconds. This is very helpful for troubleshooting poor performance.
php-cgi handles the fcgi requests. So it probably means that your PHP is doing some processing. One PHP process can easily go to 100% for some requests on some hardware (I know from my bad server). You should watch if this matches with your requests and and examine them.