I am having really difficult time with my web server. I have been tweaking things as per the suggestions on web, yet not able to find anything concrete.

My Apache process was eating 450MB under Virtual Memory column when I did htop. I searched on internet and people said that installing eaccelerator the system will become faster and efficient and would eat lesser memory and CPU. Unfortunately, this turned out to be worse than before. Now my apache processes showing 1488MB memory under Virtual Memory column.

  1. Although each process shows 1488MB memory, I can see that total RAM consumption is just 7GB that too when 4GB has been taken away by Varnish Cache (I am using it as reverse proxy).

  2. I am not sure if I should worry about Virtual Memory column or not.

  3. After installing eaccelerator, my server has not went down due to consumption of complete RAM of 18GB and 2GB of SWAP space. This used to happen before. But again, its been just 1 day since I have installed eaccelerator so may be issues will start coming in day or two.

  4. Please do not suggest me to use APC...its not installing on my server.

  5. I have checked on phpinfo page of my server and found that Eaccelerator is caching the scripts. As of now it has used up some 80MB of memory (out of 1Gb assigned by me) and has cached some 900 scripts.

  6. As of now my prefork settings are -

    StartServers 8
    MinSpareServers 5
    MaxSpareServers 20
    ServerLimit 256
    MaxClients 256
    MaxRequestsPerChild 100

Please find below the screenshot of htop.

FYI - Its a dedicated server and has 8 core CPU.
Till the time my server is up and running my site performance is excellent. It loads in around 8 sec for the first time and second view is 2.5 seconds. The site is image heavy as its an ecommerce site.

enter image description here

3 Answers 3


How a Unix system uses memory is a very long and complicated story. Adding up the virtual size of each process does not give an accurate figure of what's going on. A far better approach is to track the number of httpd process and the available memory (less buffers/cache) as reported by 'free'. Then plot these on a graph and to get a more realistic measure.

While in your case, this is somewhat complicated by having varnish running it will still give you a good indication of how demand affects memory.

You've not provided any information about how you've configured KeepAlives which have a big impact on memory usage and performance. Nor have you provided any infomration about the pattern of activity on the server - how does the number of httpd processes vary throughout the cycle? Without knowing this its impossible to comment on how appropriate the conf details you have provided are. However your MaxRequestsPerChild is very low unless you suspect that there is a big problem with your code.

Also without knowing more about the relative volumes of content types it's tricky to say what would help - e.g. if you serve up a lot of static CSS, JS and HTML, then you'll get a lot of benefits from using compression.

8Cores and 18Gb? Big Iron is the WRONG way to build a scalable webserver architecture.

my site performance is excellent. It loads in around 8 sec for the first time and second view is 2.5 seconds

I think we have different interpretations of the word "excellent"

While I suspect that there's a lot of tuning and refactoring to be done here (particularly judging by all the information which you've not supplied in your question) eventually you just need to add more hardware. In the meantime, you might want to buy in some help.

  • @syncbean - Timeout 10, KeepAlive On, MaxKeepAliveRequests 0, KeepAliveTimeout 5. Compression is ON. As far as performance of the site is concerned we targeted 5 sec first view but could not achieve it as there are around 100 product images on the home page and more than 100 product images on the sub pages. Our closest competitor is loading his site with far lesser number of images in around 5.37 sec so we believed 8 sec was excellent. initially I had MaxRequestsPerChild set to 10000 and that resulted in memory outage thats why reduced the number to just 100. Any help appreciated. Sep 9, 2011 at 15:01

If you want to reduce memory usage, you really shouldn't be using prefork but using worker threads instead. As its name implies, prefork actually starts up a new process each time, with its own memory space and what nots.

So, change your apache to use worker mpm instead. That should help a bit.

That said, if you have 18GB of RAM, what's the problem with using 7GB for apache? You've got plenty left over for other things.

Maybe you could explain further, what it is that you're trying to achieve.

  • I read on internet that for using "Worker" Apache has to be installed like that from the very beginning i.e. some different compilation to be done. I think its not there with my Apache installation because the system does not support "worker" when I tried once. As of now its showing 7GB RAM consumption...but at times it grows and eats up all my 18GB RAM as well as SWAP space. This makes the server unresponsive. Sep 8, 2011 at 8:19

Virtual Memory is what it name says. Look at the RES column for the real memory usage.

For details see man top, specifically DESCRIPTIONS of Fields section.

  • Can you please confirm if this means RES represents memory total is the RAM memory which is being used up by that process. Sep 8, 2011 at 8:16
  • Please confirm with man top
    – sanmai
    Sep 8, 2011 at 8:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .