Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My small ec2 instance with 1.7 GB memory, running the Amazon AMI based off of CentOS, has an issue with Apache utilizing way too much memory than it should. If you take a look at the screenshot, the memory usage will be at 90-100% until I reboot the httpd service, where it will start over, increasing its way back up to 90+ %.

enter image description here

I would really appreciate some assistance on how to locate the issue. Is this perhaps "normal" apache behavior, to utilize all available memory? Or is there a possible leak I have to hunt down. At the moment I'm a bit perplexed as to what could be going on.

We are using the Apache MPM prefork, and no sql or anything similar - just apache. The website is here.

share|improve this question
1  
It doesn't appear to use any Swap so what's the problem? –  HTTP500 Jul 17 '12 at 19:15
    
Shouldn't the fact that its using so much memory be a concern? Excuse my novice experience, I guess it might be an incorrect assumption. Maybe it's normal behavior and that Apache is designed to use all the memory it can grab, despite being a low-traffic website? –  Paul Jul 17 '12 at 19:19
1  
I noticed that you're using NewRelic, which can also log time spent in apache (might be helpful) if you add this line to your httpd conf: RequestHeader set X-Request-Start "%t" if you haven't already. This will appear as "Request Queuing" when you go to App Server > Overview -- might help you get to the bottom of the issue. –  KM. Jul 17 '12 at 20:32

2 Answers 2

up vote 6 down vote accepted

As HTTP500 said, you probably shouldn't worry about it unless the machine is actually choking. Take a look at Help! Linux Ate My RAM!. It's not quite an analogous situation, as you have processes rather than buffers using up the RAM, but it's not too far off: your machine's physical RAM is a resource to be used, either with kernel buffers or spare Apache worker processes to promptly handle incoming requests. If you're not using RAM, you've overpaid for the size of your box.

Anyway, if you want to play with MPM settings, the Apache documentation is http://httpd.apache.org/docs/current/mod/prefork.html

You can perhaps reduce the MinSpareServers, StartServers, etc., as you've stated that the site is low traffic. You will then have more free RAM to be consumed by kernel buffers for their nefarious purposes.

share|improve this answer

linux using all your memory is normal, memory which isn't in use otherwise is re-purposed as disk cache. see: linux ate my ram

You can verify this by looking at the output of free -m and expect to see something like this:

             total       used       free     shared    buffers     cached
Mem:          7889       6887        101          0        106       2307
-/+ buffers/cache:       5373       3416
Swap:         1903         17       1886

the +/- buffers/cache line is the one you want. It adds cached ram to free to give you a better picture of how much memory is really available. In this case, You want to pay attention to the 3416 number, not 101.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.