Explain memory - cached, shared, buffers and free

Posted on 2011-03-20
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?

Question by:mstrelan
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 35178476
LVL 10

Author Comment

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.

Expert Comment

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...)?
LVL 10

Author Comment

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?

Accepted Solution

Anton74 earned 500 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.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

724 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