1753672 Members
5856 Online
108799 Solutions
New Discussion юеВ

Swap Space Help

 
SOLVED
Go to solution
Steven Chen_1
Super Advisor

Swap Space Help

Hello,

I would like to seek opinion about the swap size whether it is enough:

right now I have 1G memory, so 2G swap space has already in place. In the near future I am going to increase physical memory to 2G, but I don't have much space for swap anymore.

Question:

Would 2G swap size still be OK? Any impact such as process crash would occur?

Thanks a lot if offer any help and comments.

Steven
Steve
6 REPLIES 6
S.K. Chan
Honored Contributor
Solution

Re: Swap Space Help

First of all you have fulfilled the "at least" requirement for swap configuration nowadays ie having 1:1 ratio of swap to RAM, in your case 2:1 ratio. It's a good start and you'll have to monitor how your system is utilizing the swap space when it is running at "full-steam", you can quickly look at swap utilization with :
# swapinfo -tam
So for now analyze your swap space utilization and set a baseline for future comparison.
Now to answer your question "2GB swap still ok?" .. When you add your additional 1GB RAM which makes it 1:1 the pseudo-swap (swapmem_on) will come into play if needed. By default pseudo-swap is already enabled on your system and it allows to have the "extra-virtual-swap" by reserving the space from the RAM upon system bootup. Again at that point in time hopefully you will then have an idea how the system behave and be able to decide if you need more actual swap space.
Ross Martin
Trusted Contributor

Re: Swap Space Help

System performance can be effected greatly by not having enough swap configured
on the system. Some of the effects that a system can have are not being able to
access all of the physical memory that is installed on the system. The kernel
will only allow a process to spawn if there is enough free space within the swap
area for the process. Applications also rely on swap, and will produce memory
related errors such as malloc or fork failed when there is not enough swap
configured. If the system does need to swap processes from physical memory to
swap area, additional disk I/O will be performed. The kernel will also use
additional resources to monitor memory and to handle the movement of the
processes to the swap device. This additional overhead will reduce system
performance. If the problem is serious, it is possible for the system to use all
cpu or other resources on process management. Once the system has reached this
state, it is refereed to as Thrashing..

You should at least configure a 1:1 ratio of swap to physical memory. This is a
fundamental ratio that will allow you to access the entire physical ram and to
handle most of the operating system's needs for swap. However, applications
that you install may need additional swap configured. You should contact the
vendor or supplier for recommendations for additional swap. It is not uncommon
to find systems with 4 times the amount of swap as physical memory.

If you were interested in learning more about swap, I would suggest reading
through the memory managment white paper. This document is stored on the system
in /usr/shar/doc and is called mem_mgt.txt. There is also information about swap
from the system administration tasks manaul(10.x) and from the configuring
systems for work groups(11.x). Both manuals can be seen at :
http://www.docs.hp.com.
U.SivaKumar_2
Honored Contributor

Re: Swap Space Help

hi,
if you are running same applications with same user load in the future also , you may not have to increase your swap space , after you upgrade your memory.
But if you want to run more applications and want to handle more load in future , you have to increase your swap space also after you upgrade your memory. otherwise you may have to face performance degradation.

regards,
U.SivaKumar
Innovations are made when conventions are broken
Steven Chen_1
Super Advisor

Re: Swap Space Help

Thanks all for the help.

I have kernel parameter swapmem_on =1, and have glance results (see attachment).

Memeory hog is Oracle db.

Any comments are appreciated.

Steven

Steve
S.K. Chan
Honored Contributor

Re: Swap Space Help

I noticed you have different priority level set for lvol1 and lvol2. I would set them both to the same priority so that interleave swap is enable which will increase swap performance. You would want to change both to priority 1, using SAM is the cleanest (not necessarily fastest) way of changing it. It'll require a reboot.
One more thing you should post after the swap priority are changed is the glance snapshot of "memory report". Run glance and in the main glance window enter "m", and post the data here.
Bill Hassell
Honored Contributor

Re: Swap Space Help

With only 1Gb of RAM, you can see that a lot of swap space is being occupied, for a total virtual memory size of more than 2Gb. Unless these programs are very lightly used (all interactive for instance), then your system is probably running very slowly. 2Gb of RAM may not be enough...you should consider 3-4Gb total RAM.

As mentioned, swapmem_on should be set to 1 so that swap space is additive. If you have 2Gb of RAM and run a total of 2.5Gb of processes, then you'll only need 700-1000 megs of swap space. The 1:1 relationship between RAM and swap is only required when swapmem_on=0 in the kernel. There are some very old stories about the required swap space being 2x to 10x RAM size. That has not been true for more than 7 years.

The key to looking at RAM and swap is: when RAM is too small then paging (swap) will occur and everything will run VERY slowly. The PO metric from vmstat (or Page Outs in Glance) indicate actual paging. Dozens to hundreds of pages means RAM is way too small.

If the page out rate is low but processes complain about running out of RAM (malloc error, etc) there can be several reasons. First, there must be enough swap space to hold everything that overflows from RAM (plus some for memory mapped files). If swapinfo -tm does not show full swap areas, all is well. If it is almost full, then add more swap--as long as the page out rate is not high. If it is high, add more RAM rather than swap space.

However, processes will complain about memory when they encounter a kernel fence such as maxdsiz. Unfortunately, the error message can't define the true reason, so increase maxdsiz to be larger than the largest program. Programs may also complain about shared memory and this is a long topic for 32bit programs. For the details, look at the white papers in /usr/share/doc on process and memory management.


Bill Hassell, sysadmin