Linux server needs a RAM upgrade? Check with top, free, vmstat, sar

Originally published at: Linux server needs a RAM upgrade? Check with top, free, vmstat and sar.

Sometimes, it can be a bit of a challenge knowing if and when you should upgrade the RAM (random access memory) on your Linux server. Even more so, when deciding how much memory you should add, or if you have adequate memory, how do you make the best use of it? This article will walk…

1 Like

How about this server? Do you guys think it needs a RAM upgrade? It’s starting to swap:

1 Like

Does not seem that way, it’s showing a massive amount of cached/available memory, which is healthy. Load avg also seems fine.

Sharing the output of free -m should confirm this.

You should change the vm.swappiness value to a lower one. This will reduce how aggressive linux is with ram swapping. It’s easy enough to find out how.

You can refer to this post on the ubuntu forums as it includes applying permanent changes.

Also the numbers do not quite line up on memory. 7/58GiB of memory used… but the bar is full?

@hydn Here’s the output of the free command:
image

Thanks. So as suspected, everything looks healthy. You have over 50G of available memory. As per the article:

> available = Estimation of how much memory is available for starting new applications, without swapping.

This means that the 330M of swap used is extremely likely to be opportunistic swapping which is also healthy. Also, from the article:

> “This is from opportunistic swapping. Or swap performed during idle moments that do not negatively impact the server’s performance.”

Personally, I wouldn’t reduce vw.swappiness. You should tweak this only if you notice frequent swapping that affects performance. By reducing, it’s likely the 330M of memory freed up would instead still be sitting in buff/cache. It’s an insignificant amount now, but everything is flowing in the right way.

I’d say just let things run. Set up server monitoring so you can see when swapping occurs and be sure it’s always during idle server time.

Example:
image

Opportunistic swapping ref: Linux Performance: Almost Always Add Swap Space - #17 by xenyz

Hope this helps.

okayyyyyyyyyyyyyyyyy nicee