Solved

Explain memory - cached, shared, buffers and free

Posted on 2011-03-20
5
638 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
Comment Utility
0
 
LVL 10

Author Comment

by:mstrelan
Comment Utility
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
Comment Utility
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
Comment Utility
@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 500 total points
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now