Cutting Apache preforks seems to help small web servers

I’ve had a ton of downtime this week (this seems to be the busy time of year for my web server), but I think I traced the problem to a known issue.

My server has a 1.5 GHz single-core CPU and 1 GB of RAM, making it less powerful than a $150 tablet these days, and that probably qualifies it as a low-end web server. Its replacement is waiting for me to have half a day uninterrupted to get it running and all my data moved over, which could be a while.

So in the meantime, it’s quick-fix time.

The problem is that the server has been running out of memory. This appears to be a fairly common problem with low-end servers running Apache and MySQL–Apache slowly grows to consume all available memory, and eventually squeezes out MySQL, and MySQL crashes, sometimes bringing the whole system down with it.

I found this tweak to tame Apache’s memory usage. Load /etc/apache2/apache2.conf into your favorite editor, and scroll to this section:

<IfModule mpm_prefork_module>
StartServers          3
MinSpareServers       3
MaxSpareServers       3
MaxClients            50
MaxRequestsPerChild   1000
</IfModule>

Mine had been set by default to 5, 5, 10, 150, and 0, respectively.

Since making the change, my memory usage has been much more consistent, and while it’s too early to tell if it’s helped performance, it doesn’t appear to have hurt performance at all.

Ultimately I need to replace the server. My goal was to take my server into the 64-bit era, and I ran into a snag doing that. Even if I can only get 32-bit Linux running on the machine for now, a dual-core, 2 GHz machine with 4 GB of usable RAM is an improvement over what I have, and I might as well take what improvement I can get, then go back for more performance later.

%d bloggers like this:
WordPress Appliance - Powered by TurnKey Linux