Ubuntu running Apache Server (Prefork) PHP Fast-CGi High CPU Usage

apache-2.2central-processing-unitdrupalphp-fpmubuntu-10.04

I have a server running very slowly due to high CPU usage. I think this must be a configuration issue but I can't put my finger on why. The server is running Plesk and I've configured PHP to run as a Fast CGi application.

Server spec:

Quad-Core AMD 2.2GHz
4GB RAM
Ubuntu 10.04
Apache 2.2.14
PHP 5.3.2

Websites:

1 x Drupal 7
2 x WordPress 3.x

Apache config:

KeepAlive On
Timeout 30
MaxKeepAliveRequests 0
KeepAliveTimeout 2

<IfModule mpm_prefork_module>
    StartServers          4
    MinSpareServers       5
    MaxSpareServers       10
    MaxClients            20
    MaxRequestsPerChild   5000
</IfModule>

Notice the high CPU

I have APC enabled plus the Drupal site has all caching turned on, including caching in views. I have another server running over 100 sites on CentOS and cpu usage is very low. Any ideas what could be causing this?

Heres a mod_status output screenshot

enter image description here

Also there is no output in the apache error.log apart from MaxClients being exceeded.

top CPU and Memory lines added 25th Apr
enter image description here

Best Answer

No amount of Apache or PHP tuning will help you, it's time to see what makes Drupal or Wordpress so slow. I guess you have some custom modules in one or both of them and some custom module is dragging the performance down. Try disabling custom modules one by one and see if that helps. Also enable logging in your database and spot the slow and/or excessive queries.

When it comes to Drupal, Boost can be an excellent performance boost. With WordPress, W3TC tends to help a lot.