Friday, May 26, 2017

linux - Web Server Running Low in Memory



I have an EC2 small instance that has 2 gigs of memory, running Fedora Linux.



Typically, I get about 275 page views per day on average, and I have a monitoring agent on the box. Some of the stats are little worrying in terms of free memory.



Last week, at it's lowest point we had only 30 mb free of memory, this morning it appears to have increased to about 150 mb. Hyperic is our monitoring agent which runs Java. A top shows that its memory usages is only about 3.4%.




When I add up all of the httpd processes I get about 15-20% memory usage with mysql using about 1%.



Top doesn't reveal where the rest of the memory is going. What could I do to find out whats causing the high memory consumption? Could it be the 275 hits a day? About 95% of our code is PHP and HTML. MySQL is being used lightly from an application called OpenVBX which is only used internally.



If it's apache, an upgrade in memory should solve our issue right?



Any advice would be a huge help, thanks!



UPDATE: free shows this:




             total       used       free     shared    buffers     cached
Mem: 1718724 1575024 143700 0 234328 969284
-/+ buffers/cache: 371412 1347312
Swap: 917500 1140 916360

Answer



Basically you want to look at the free column of the buffers/cache row, so you have about 1.3G free -- you are probably in good shape.



The famous page for this "Help! Linux ate my Ram!" at http://www.linuxatemyram.com/ .




To put it very simply, Linux is going to use ram to cache files and the sort so it can deliver them faster. If a program really needs ram then it will take it from the cache -- but why not use the ram while it can?


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...