How to manage runaway PHP procs for a site?

ylluminate

Member
Apr 12, 2013
16
2
3
cPanel Access Level
Root Administrator
I have a particular site that is being a real hassle. They're running WordPress, but php processes seem to be spawning to the point of being far beyond any other sites on the system. I frequently find them chewing away on 16-20 of the processor cores at 100% levels for each and I am also experiencing `-bash: fork: retry: Resource temporarily unavailable` when I ssh in as the user. Root and other users seem okay, except for the sluggishness of the system being chewed up by this user.

What should I do to manage situations like this better? I have contemplated killing php procs with a cronjob to just look for php procs > 1 hour. I have also considered adjusting the ulimit for this user as well... but I am just not sure what the "best" approach to take may be for this scenario, especially given perhaps preferred cPanel options if there are any.
 

ylluminate

Member
Apr 12, 2013
16
2
3
cPanel Access Level
Root Administrator
FYI, here is a script that I wrote to kill php processes (I have it set to kill them all with pid runtime > 1, but that can be adjusted to 3600 for an hour; and you would want to replace USERNAME with a desired username there): /https://gist.github.com/996c8ab0609811425457

This doesn't seem to resolve the performance problem though for the site and a slew more php processes appear to spawn fairly rapidly again for this WordPress site.
 

ThinIce

Well-Known Member
Apr 27, 2006
352
9
168
Disillusioned in England
cPanel Access Level
Root Administrator
In my experience, this isoften either a site in need of a caching plugin (i.e. wp_supercache or similar) or a site being scanned by a vulnerability finding tool. I'd suggest taking a look at the apache log for the site, this may indicate what's happening (the latter case will for example have lots of requests to plugin files that aren't actually installed).