Apache being a memory hog

I'm sure that everyone here uses their servers for some minimal web-serving. Apache also has multi-threading, and multi-process abilities (of which I'm not very knowledgeable in).

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

If you are not expecting a bunch of visitor's you can reduce the nbr of threads that start – and the nbr of spare servers that start. This should help out -- however would slow your site down if you had a windfall of visitors.

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:

http://www.acme.com/software/thttpd/

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:

http://www.aprelium.com/index.html

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.)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct