1753536 Members
7434 Online
108795 Solutions
New Discussion юеВ

Swap-mem

 
Roger Baptiste
Honored Contributor

Swap-mem

Hi,

I have a database production server (V-class). 14Gb RAM ; 14Gb device swap (i.e 14 one Gb raw lvs) and pseudo-swap on.
Swapinfo -mt shows swap usage between average 40-50% with all the dev swap entries showing 0% usage and pseudo-swap usage is the same as total swap usage. (sample output:
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 1024 0 1024 0% 0 - 1 /dev/vg00/lvol2
dev 1024 0 1024 0% 0 - 1 /dev/vg00/lvol9
dev 1024 0 1024 0% 0 - 1 /dev/optvg/swap1
dev 1024 0 1024 0% 0 - 1 /dev/optvg/swap2
dev 1024 0 1024 0% 0 - 1 /dev/optvg/swap3
dev 1024 0 1024 0% 0 - 1 /dev/optvg/swap4
dev 1024 0 1024 0% 0 - 1 /dev/vg00/swap5
dev 1024 0 1024 0% 0 - 1 /dev/vg00/swap6
dev 1024 0 1024 0% 0 - 1 /dev/vg00/swap7
dev 1024 0 1024 0% 0 - 1 /dev/vg00/swap8
dev 1024 0 1024 0% 0 - 1 /dev/vg01/swap9
dev 1024 0 1024 0% 0 - 1 /dev/vg01/swap10
dev 1024 0 1024 0% 0 - 1 /dev/vg01/swap11
dev 1024 0 1024 0% 0 - 1 /dev/vg01/swap12
reserve - 7847 -7847
memory 11146 4472 6674 40%
total 25482 12319 13163 48% - 0 -


Apparently, device swap is not being used. The memory usage is around 65% average and 85% peak.

My question is, if i disable pseudo-swap, would there be a reduction in the memory usage value? I know, everything looks good and there is no need to change it. But, the 85% peak is provoking constant questions from the user groups who would like to add more memory for future growth. i am toying with the idea of disabling pseudo swap to decrease the memory usage value. any thoughts? any body tried this? Wouldn't this increase the cpu load, since the device swap kicks into play?

Again, this has been an oft-discussed item and i know it is good to use even 100% memory , but dealing with "experts" who go by numbers alone is proving to be tedious. Hence i am probing this approach.

thanks!
Take it easy.
8 REPLIES 8
A. Clay Stephenson
Acclaimed Contributor

Re: Swap-mem

Pseudo-swap memory is not being used; it doesn't exist. It only serves a role in boxes with more memory than actual disk swap space. It is a way of telling the box that I know I don't have enough disk if I must swap BUT I'm not going to swap. There is no reason to enable pseudoswap in the case of disk swapspace >= physical memory; you are adding a bit of system overhead for nothing.
If it ain't broke, I can fix that.
Stefan Farrelly
Honored Contributor

Re: Swap-mem


Your'e looking at the memory line from the swapinfo command the wrong way. What it should really say is memory_swap (not physical memory). Pseudo swap (the memory line) is a safety net in case you run out of device swap, thats all. As you have 14Gb of RAM and 14Gb of device swap you dont need pseudo swap or even have it switched on - seeing as its only causing confusion amongst user groups who cant possibly understand its meaning.

The reserve line from swapinfo shows you have only 7,847Mb of memory used for user programs (not including kernel+root processes) which is available for paging if need be.
The memory line shows 4472Mb already used - this is not really used but 4472Mb of memory locked by processes so it is not availble for use as pseudo swap (or memory swap) thus swpainfo shows it as being already used (or unavailable). This 4472Mb would be used by things like database shared memory or SGA - thats why its locked and is not available for use as memory swap.

To stop confusion I would simply turn pseudo swap off. Instead just supply users with the output from vmstat (free memory pages * 4096) so they can see in reality how much memory is used and how much is free. Remember, as Bill Hassel said, using all your available RAM is a GOOD thing - it means you arent wasting any and your using it to enhance performance. Its only if you use more memory than you have RAM that you start causing problems.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Ben_31
Advisor

Re: Swap-mem

Every good reference I have seen on Monitoring system performance on UNIX boxes has told me not to worry so much about percentage of RAM used as long as there was still free swap space available.

They said that if you really wanted to know if there was a memory crunch you should look at the page activity columns with the vmstat commands. Especially the scan rate.

I have a lot of systems with a pretty even spread between 256MB of RAM to 4GB of RAM. They all run big databases and lots of processes, and they all seem to use about 85% of Memory after they have been running for a few days. This seems to be completely normal. I don't expect that a system would use less memory than that unless it just had an obscenely large amount of RAM for the amount of programs and data it was working with.
Frank Slootweg
Honored Contributor

Re: Swap-mem

> The memory usage is around 65% average and 85% peak.
...
> But, the 85% peak is provoking constant questions
> from the user groups who would like to add more memory
> for future growth.

*What*/*where* is this "memory usage" displayed? I.e. which utility and which (name) field? If "Mem Util" in Glance, then believe the experts, 85% is good and 65% is bad.

If I were you, I would *not* disable pseudo swap. As has been discussed many times before, disabling it has only disadvantages for 99+ percent of the cases (And no, you're not in the 1- percent! :-)).

Same advice as always: *Always* use the "-t" option of swapinfo(1M) and *only* look at the "total" line. It makes everyone's life so much easier, including ours! :-).

Bill Hassell
Honored Contributor

Re: Swap-mem

Since you are not using all of your memory, you have about 12 Gb of wasted disk area. Many, many years ago, swap was calculated based on a formula such as RAMx2 but today, it is a meaningless formula. If you have swapmem_on=1, then you need 1-2Gb of swap space. For large memory systems, setting swapmem_on=0 means that you must have at least RAMx1 swap space but it will never be used except through some bookeeping in kernel memory.

Don't use swapmem_on=0 and return all the extra swap space other than 1-2 Gb. Then monitor swapinfo -tm regularly to see if actual device swap is being used. Once total device swap nears 75%, add another Gb.


Bill Hassell, sysadmin
Roger Baptiste
Honored Contributor

Re: Swap-mem

Hi,

Thanks for the responses. As expected, pseudoswap brings forth contrasting responses from the 1 and 0 camps ;-) I belong to the 1 camp; i prefer to set it to 1 by default, since all my systems have memory in the ~>8Gb range and it's worked fine. Isn't it better to keep everything in the RAM. As far as this "problem" was concerned, i was referring to the memory usage of 65-85% from the Glance output. (and not swapinfo output as some folks construed) and the users refer to glance output as well.

Ideally, i would like to turn pseudoswap off and monitor it's effect overall on the system and see whether it makes any difference vs with pseudoswap on , but this being a production system, any experimentation is ruled out ;-) and the problem is no longer there, as far as users are concerned.

thanks!



Take it easy.
A. Clay Stephenson
Acclaimed Contributor

Re: Swap-mem

You still don't quite get it. Yes, it is great and desired to fit everything in memory. I would guess that most modern machines run in that mode and that swap is not utilized very much at all. I certainly buy enough memory for my boxes to run like that.

Here's the deal in your case; if you have 1x RAM as swap then swapmem_on=1 does absolutely nothing other than add a little kernel overhead. Your logically consistant choices are 1) leave swap as it is and set swapmem_on=0 OR 2) reduce swap to 1-2GB and set swapmem_on=1. You will then regain a big chunk of wasted disk space and a really big chunk if your swap is mirrored (and it should be).

The important point to remember is that enabling pseudoswap does not mean that you are swapping in memory.

If it ain't broke, I can fix that.
Trond Haugen
Honored Contributor

Re: Swap-mem

With your current swap-config turning psudoswap on or off will not affect the performance. So in my view the "best" thing you get from turning it off is not having that memory line in swapinfo.
Having said that I would also have kept pseudoswap and decreased dev-swap.

Regards,
Trond
Regards,
Trond Haugen
LinkedIn