I have installed Apache 2.2 and it runs like a charm. The problem is, that system sometimes becomes slow on high load, or when a large number of simultaneous users access the same php file.

Going over the server performance logs in Splunk I noticed that Apache uses CPU very efficiently, and create separate treads every time a spike occurs, and deals with the CPU consumption in a very brave way.

Nevertheless this specific server has more available memory than CPU power, and I would like to know, if there is a way, to make Apache rely more on the RAM than CPU when handling different tasks. AT the moment it seems like the best option in increasing the Apache performance in the particular setup.

Our server has 4CPU cores (2.2 GHz) each, and 8GB or RAM.

When a load occurs we usually see only 700MB of RAM used, but 80-90% of all CPU consumed by Apache. Is it logical to assume, that by increasing the "limit" of memory Apache handles, we could push the user limit up?

What would be the steps to change Apache to work this way?


Do you have an PHP opcode cache installed? e.g. php-apc or xcache?

usual recommendations:

  • reduce default loaded apache modules which you won't need
  • try using different settings for Timeout, KeepAlive, MaxKeepAliveRequests and KeepAliveTimour
  • plot some graphs to be able to analyze your system better (with cacti/munin/etc.)
  • Post output of "vmstat 1" during peak times

Look at using apaches mod_expires and deflate.


create separate treads every time a [cpu] spike occurs

Is this the threaded server as opposed to the pre-fork then?

Do you think the spikes might be a consequence of spawning more processes? If so then I'd recommend running with more processes (but the same number of threadsperchild). Also making sure you've got a high value (not 0) for maxrequestsperchild.

Certainly you want to ensure that you have more idle httpds running. How you go about that depends on whether its a prefork or threaded apache.

It would have been helpful if you'd provided your current core settings along with details of how you've configured PHP and what OS this runs on.

As others have said, enabling compression. mod_deflate will only work with the static content - for PHP you need to add zlib.output_compression = On in your ini file. While a trivial analysis og this suggests it increases the amount of work doen by the CPU, in practice it means that the server is freed up sonner (and so scheduled less frequently).

For preference php should be running as mod_php, failing that, via fastCGI - if it's running as CGI, then what do you expect? Again, an opcode cache will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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