Apache setup

A record of how I made this site perform OK (with no load) on my 256MB RAM virtual server running Ubuntu 8.04 (yes I know that’s quite old).

Apache was configured to use prefork, and I hear PHP generally tends to work better with prefork, so I stuck with that.  The main tuning is therefore in the number of processes allowed to run.

As soon as a process has run some PHP it gets big and hogs a bunch of memory.  However, I don’t think there is a way to dedicate some processes to PHP and others to serving media, so in order to keep the memory limit sensible we need to kill off excess processes that have run some PHP in them reasonably quickly.  This was a bit counter to my original expectation that you should keep a set of worker processes hanging around.

I ended up with

# 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          5
    MinSpareServers       2
    MaxSpareServers       5
    MaxClients            20
    MaxRequestsPerChild   50
</IfModule>

which appears to be working pretty well.  As long as I don’t get slashdotted!

Leave a Reply

Your email address will not be published. Required fields are marked *

*