Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some trouble with a server, could really use some advice. Memory usage is fine and system load is fine. CPU usage is incredibly high, slowing the site down significantly. It's running a heavily-customized version of Drupal. It's an EC2 large instance (8 gb, not sure about cpu).

Here is my apache config:

# Timeout: The number of seconds before receives and sends time out.
Timeout 40

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
KeepAlive On

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
 KeepAliveTimeout 5

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
StartServers           8
MinSpareServers        5
MaxSpareServers       20
MaxClients           125
MaxRequestsPerChild  400

I'm using prefork. Any ideas?

share|improve this question
What are the specs on your CPUs? How many & clock speeds? – KM. Nov 9 '11 at 20:14
Are you using APC or another opcode cache? – HTTP500 Nov 9 '11 at 20:18

The CPU usage is propably from Drupal or PHP and cannot be affected with apache settings.

share|improve this answer

Your first job should be to try to pinpoint which requests are causing the high CPU usage. MySQL and Apache are both heavy CPU users. If you know the cause you can more easily optimize it.

Of course, fixing the cause would be best. However you can also perform miracles with caching.

An easy first step is to implement an opcode cache, like APC or Zend Optimizer+. This will cache compiled PHP code, reducing the need to compile this again on the next request.

Second, make sure Drupal is caching all that it can. See Drupal caching, speed and performance.

Third. implement Varnish, a reverse proxy cache, to cache all static content and all dynamic content that is not actually that dynamic. This will be easiest if your using Drupal 7 or Pressflow. Varnish can serve thousands of requests per second with a lot less CPU than Apache needs to serve a few, so any requests that you can offload to Varnish will lighten your load. It has made a serious impact on our web servers. Check for tips.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.