None

Tuning Apache for 512Mb Memory

April 25, 2010

I have a Virtual Machine running Debian Lenny with which to host web sites. It was swapping a lot, so I've just updated the memory from 256Mb to 512Mb.

After the upgrade I was having trouble with some websites being slow. Using the Net panel on Firebug this seemed to be down to static files taking longer to serve than necessary (sometimes up to 15 seconds) even when they returned a 304 Not Modified header.

The problem appears to be down to my Apache settings. I was previously using:

<IfModule mpm_prefork_module>
  StartServers          2
  MinSpareServers       1
  MaxSpareServers       1
  MaxClients           30
  MaxRequestsPerChild  50
  ServerLimit           5 
</IfModule>

I've now modified this so that ServerLimit is the same as MaxClients. This seems to make more sense, and results in the problem files now loading in a matter of milliseconds.

<IfModule mpm_prefork_module>
  StartServers          2
  MinSpareServers       3
  MaxSpareServers       5
  MaxClients           30
  MaxRequestsPerChild  50
  ServerLimit          30
</IfModule>

ServerLimit is defined in the documentation as For the prefork MPM, this directive sets the maximum configured value for MaxClients for the lifetime of the Apache process., which to me means it doesn't make sense to have this smaller than MaxClients.

I've also changed the spare servers settings so that I'm not restarting server processes quite so much just because no one has visited.