Diagnose Apache CPU usage by Site

SYSTEM INFORMATION
OS type and version Ubuntu 20.04.6
Webmin version 2.101
Virtualmin version 7.8.2.gpl-1
Related packages SUGGESTED

Hi folks, my googling has not been getting me information I would hope to find. The above server is running on ESX with 4 CPU and 16 GB RAM.
I am have decently high RAM usage and several times where CPU runs at greater than 80%. I’ve resorted to daily reboots which are working OK as a band-aid, but not where I really want to be.

What I’d like to be able to do is correlate mysqld and apache2 PIDs to specific sites. I’ve tried some strace commands I have found on the internet, with no real answer. Using htop, most of the users appear to be just mysql and www-data.

Any advise on tools I can use that will show me which sites are the worst offenders for CPU and/or RAM usage?

TIA

Single server/VS what are the Load Averages like for CPU or is this another case where it just creeps up to unreasonable level?

There are other reported cases on here that have been reported (do a search for “CPU high”)

As always the logs are your friend, especially php if it is a php based website at fault or mail logs.

Use the htop package then sort the CPU column in descending order. Check in real time which process overloads the processor cores. If you are using a VPS/VDS and its resources are shared with someone else and you find that no process is overloading your virtual machine, then talk to the service provider.

That makes me think you’re using mod_php, which you should not do.

The web server almost never consumes much CPU, except when it’s also running your applications, which is the case with mod_php (and mod_perl, and some other mod_language) modules. You should be using php-fpm, which would show the CPU usage belonging to the user that owns the domain, at least in the configuration we use in Virtualmin.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.