I recently down-scaled the server which hosts this blog (one among a few). Being a Ubuntu server, it was trivial to install the LAMP stack, including Apache 2. However, I quickly discovered a problem with the default configuration on a server with a lesser amount of memory (in this case 512MB). The server would work just fine for a short while and then grind to a near halt, where even a SSH session becomes unusable. When I eventually got into the server, I listed the processes and found the ‘apache2’ process running several dozen times!
The default configuration for the Pre-fork MBM (Multi-Processing Module) reads as follows:
# prefork MPM
StartServers 16
MinSpareServers 16
MaxSpareServers 32
ServerLimit 400
MaxClients 400
MaxRequestsPerChild 10000
To something more reasonable to a server with limited memory, such as:
# prefork MPM
StartServers 4
MinSpareServers 4
MaxSpareServers 8
MaxClients 35
MaxRequestsPerChild 10000
I found this has made my server much more stable – and I’ve not noticed any performance decrease from the new configuration.