?
Solved

Explain memory - cached, shared, buffers and free

Posted on 2011-03-20
5
Medium Priority
?
649 Views
Last Modified: 2012-05-11
Hi experts,

I have recently installed some server monitoring software on my web server which has the ability to send me various alerts. I can set the alert based on Cached, Shared, Buffers or Free but I have no idea which is most relevant. I'm guessing a combination of shared and buffers.

The server has 1.5GB ram and is hosting a website that is getting around 1000 visits a day but that is expected to increase steadily (or rapidly). In the last hour it has averaged

Cached: 1067MB
Shared: 226MB
Buffers: 76MB
Free: 107.22MB

What should I be looking out for?

Regards,
Michael
0
Comment
Question by:mstrelan
5 Comments
 
LVL 12

Expert Comment

by:upanwar
ID: 35178476
0
 
LVL 10

Author Comment

by:mstrelan
ID: 35178535
Does not really help ... what I want to know is what sort of figures would be alarming. For example perhaps Shared should not exceed 1GB.
0
 
LVL 9

Expert Comment

by:Vampireofdarkness
ID: 35178538
My $0.02 would be to monitor free memory. In theory the cache will fill up until the memory it uses is required, then it'll start to clear the oldest information first.

Are you able to set a maximum cache size? What is the size of the content you are serving? How is your visitor load distributed (all between 6AM and 8AM, throughout the whole day, 6AM - 10PM, etc...)?
0
 
LVL 10

Author Comment

by:mstrelan
ID: 35195850
@Vampireofdarkness - if I understand correctly I should only be alarmed when free memory hits 0? In which case linux will start freeing up memory from cache anyway? I would have thought it would be good to monitor the amount of Shared memory, so I could be alarmed when it is using say 50% of the memory. And perhaps monitor swap space?
0
 
LVL 9

Accepted Solution

by:
Anton74 earned 2000 total points
ID: 35196034
The OS tries to make the most efficient use of RAM. It will use lots of RAM for cache if it can (meaning, if it's not otherwise needed), and with growing RAM demand it will be less, but normally never zero. Put somewhat differently, because unused (free) RAM is not useful until it is actually used, the OS will happily use it for cache rather than keep it free. Because of this, free memory is typically low; cache memory is easily and quickly freed as otherwise needed.

Between the numbers of cached/shared/buffers/free, shared and buffers tend to be a pretty low number and won't tell you much, so you'd want to focus on cached and free. Individually those won't tell you very much because free memory is almost always low as it'll be used for cache as explained above, but you can look at how much free memory you would have not considering cache - this is actually displayed on the second line. To really put this in useful perspective you have to compare to the amount of physical RAM you have. In your example, you have 1.5GB of RAM, and after subtracting cache and free memory only a few hundred MB is really used by programs (and the kernel), so you currently have plenty of RAM to spare.

The very best indicator of running low on RAM in my opinion is swap space usage. Very low swap usage is fine, but when it starts to become a significant amount (relative to the amount of physical RAM) it will affect performance. Nothing will kill performance like lack of RAM because it results in high swap file usage, and this tends to result in continuous disk activity (thrashing), grinding things to a halt.

To provide some rough percentages based on my opinion and experience (and the actual impact depends on the type of workload), swap file usage of about 5-10% of physical RAM means you are fairly moderately short on RAM, 20-30% it starts to get pretty noticeable and much above that it'll start to really hurt. Most OSs by default provide for something like 1 to 2 times the amount of RAM in swap space, but if you have anywhere close to that in actual swap usage, you probably won't have any performance left.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question