LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Swap memory treshold - warning - critical (https://www.linuxquestions.org/questions/linux-newbie-8/swap-memory-treshold-warning-critical-935460/)

kopper27 03-20-2012 08:17 AM

Swap memory treshold - warning - critical
 
hi guys

the monitoring team is using a tool for monitoring linux boxes and they set an alarm for swap memory to 10%(critical) I really has no idea when swap memory usage is high....

Can someone recommend me a threshold for this? when is warning or critical and this parameters can affect performance in my Suse Linux boxes?

for instance 1 box has been having "peaks" of 14% during last days....they don't know if the box has issues but they see the alarms and today another box had a peak of 64% and they are worried should they? basically they told me these 2 boxes should not have peaks like that they should be 0% swap usage....so how they say that

thanks a lot

MensaWater 03-20-2012 08:42 AM

swap utilization size all by itself doesn't mean that much. swap and physical memory combine to create virtual memory. Applications preallocate address space at start up and by having more virtual memory you can start more things than you could if limited to physical memory.

What you need to know is pageins/pageouts. This is what tells you not just if swap space is being utilized but whether in fact you are "paging" (swap is an old term still used but modern *NIX does paging rather than swapping). If you have a high number of pageouts AND pageins it means that the system is memory constrained so is having to push parts of active processes out to swap and then call them in. Since this reduces memory calls to disk speed it impacts performance.

You can see pageins and pageouts with vmstat (si and so columns).
vmstat 5 5

Also if you have sar installed and running you can get hourly statistics with "sar -B".

It is retarded to say swap should always be 0. If that were the case you wouldn't need to configure swap in the first place.

kopper27 03-20-2012 08:48 AM

Quote:

Originally Posted by MensaWater (Post 4631549)
swap utilization size all by itself doesn't mean that much. swap and physical memory combine to create virtual memory. Applications preallocate address space at start up and by having more virtual memory you can start more things than you could if limited to physical memory.

What you need to know is pageins/pageouts. This is what tells you not just if swap space is being utilized but whether in fact you are "paging" (swap is an old term still used but modern *NIX does paging rather than swapping). If you have a high number of pageouts AND pageins it means that the system is memory constrained so is having to push parts of active processes out to swap and then call them in. Since this reduces memory calls to disk speed it impacts performance.

You can see pageins and pageouts with vmstat (si and so columns).
vmstat 5 5

Also if you have sar installed and running you can get hourly statistics with "sar -B".

It is retarded to say swap should always be 0. If that were the case you wouldn't need to configure swap in the first place.


thanks a lot for this great info
and I agree with you about no swap utilization


by the way what when I know pages in and pages out are high so I can say my server is memory constraint

johnsfine 03-20-2012 08:59 AM

Are these real or virtual systems? Memory management in a virtual machine may be strange and is certainly specific to the type of virtualization.

Quote:

Originally Posted by kopper27 (Post 4631526)
they set an alarm for swap memory to 10%(critical) I really has no idea when swap memory usage is high....

You mean 10% swap used and 90% swap free, not the other way around, correct?

Quote:

Can someone recommend me a threshold for this? when is warning or critical and this parameters can affect performance in my Suse Linux boxes?
Without knowing a lot more, we can't say what % would be a problem. For a workstation or small server I think 2GB of free swap is an appropriate margin. For a larger server, you should have a little more than that.

How much swap space and how much ram do these systems have? That info would give a little perspective on the % values you reported.
Quote:

for instance 1 box has been having "peaks" of 14% during last days....
If you have 2GB of swap and 14% is used, you probably should fix something. If you have 4GB of swap and 14% is used, there is less likely any need to correct anything.

Quote:

today another box had a peak of 64% and they are worried should they?
64% swap use sounds like a problem. If your system had unusually high swap usage for a well understood reason and someone had set the swap size to a safe margin above that, it could have 64% swap usage and be perfectly correct and safe. But that doesn't sound like your situation. Either the swap allocation is low so a reasonable use of swap space fills 64% (meaning you ought to have much more swap allocation) or you have an unexpected large use of swap space that you should examine.

Quote:

they told me these 2 boxes should not have peaks like that they should be 0% swap usage....so how they say that
0% swap usage is a foolish target. Servers should use some swap space. But servers should also have a generous margin of free swap space.

If you can run free at a moment when swap usage is "high", you can get a better idea of the overall memory state.

If the used swap reported by free is lower than cached ram reported by free, you have moderate to low swap usage. Under those conditions, I think 2GB of free swap space is a pretty safe margin.

If the used swap is greater than the cached ram, you should be worrying about both the swap in/out rates for whether the system has enough ram to do its job and the out of memory killer (whether the system has enough swap space for safe operation). In such a system, I do not think 2GB of free swap is enough of a safety margin.

chrism01 03-20-2012 06:28 PM

In addition to MensaWater's advice, you might also look at iostat http://linux.die.net/man/1/iostat.

If the alert system is currently warning you, that's good (in as much as its doing its job), but I'd also recommend graphing swap usage values regularly so that you can see the history.
This will help you pin down which process(es) is/are causing the issue.

For example we currently use Nagios for alerting & Cacti for historical graphing/tending.


All times are GMT -5. The time now is 09:53 AM.