Running Apache on Low-Memory Systems
I recently had to do some trial-and-error tuning of my Apache installation, as it’s running on a VPS with only 256MB of memory. When Apache starts leaking memory, a system with 256MB of RAM will start to swap out pretty quickly, and on a VPS, that means some serious, devastating lag.
I found that on my system, with 256MB of RAM, the following settings in apache2.conf worked very well, and provide for good load times:
If you are using prefork MPM:
<IfModule mpm_prefork_module> StartServers 2 MinSpareServers 2 MaxSpareServers 4 MaxClients 100 MaxRequestsPerChild 1000 </IfModule>
If you are using worker MPM:
<IfModule mpm_worker_module> StartServers 2 MaxClients 100 MinSpareThreads 10 MaxSpareThreads 40 ThreadsPerChild 10 MaxRequestsPerChild 1000 </IfModule>
On either MPM:
Set keep alive timeout to 5 seconds instead of the default 15 seconds.
Set apache’s timeout to 180 seconds instead of the default 300 seconds.
Warning! Do NOT just paste this stuff into your apache2.conf / httpd.conf file!!! Most of this stuff is already a setting in the file, and you need to change it, not add it.
Disclaimer: These settings worked well for me. I in no way warrant or claim that they will do anything good for anyone else, ever. I am not liable if you choose to use these settings and it makes matters worse, or causes your server to pack up its suitcase, steal your car and run away with the postman. Modifying these settings requires you to edit sensitive configuration files, do so at your own risk.
No comments yet.