Apache being a memory hog
When I start apache and visit my site a few times, there's about 12 httpd processes running, and using a tool to tell me how much memory is free, 0% and a nice sum of my swap space is being used.
When apache is shut down, I have about 50-60% memory free, and most of the swap is free.
For those who aren't hosting many websites with many hits, there must be an easy way to lower the amount of memory that apache uses, and as we all know, on a shared platform, free memory is pertinent.
Anyone with some suggestions?
- Eric
1 Reply
You can do this by editing the httpd.conf file. Not sure what distro you are using but it is most likely in /etc/apache or maybe /etc/httpd .
Just search for the line(s) as follows:
StartServers 3 # 3 is the initial nbr to start
MinSpareServers 1
MaxSpareServers 20
Make sure you read the comments in the config file about the "risks" associated with making these numbers 2 low. However the lower the numbers -- the less memory.
P.S. --- Apache's memory effect is nowhere as bad as it's usage of file descriptors. (If you are spooling out error logs, usage logs, etc… for multiple virtual clients -- your available file descriptors will get sucked up quick.)
Another option to save memory in a small memory environment is to use a different web server. thttpd is a good option:
HOWEVER --- And I hate to say this because I don't think it is open source (and that worries me)… It is however totally free and VERY easy to use -- the website is very professional and the documentation looks very complete:
Abyss web server located here:
totally ROCKS as a small footprint/memory webserver….Even with using PHP as a CGI. (When I say small footprint I mean no more than 2 processes using about 800K each….1 process is for the web based Admin console that runs by default on port 9999 on the localhost and lets you easily configure your server.)