1753432 Members
4577 Online
108793 Solutions
New Discussion юеВ

Swap space issue

 
SOLVED
Go to solution
Waqar Razi
Regular Advisor

Swap space issue

I have a system running some tomcat application on it. The users are having some performance issues and the application owner are pushing this issue on us that it is due to swap space.

Here is the output of the free command:

# free
total used free shared buffers cached
Mem: 16436856 16349104 87752 0 1912 1105768
-/+ buffers/cache: 15241424 1195432
Swap: 16779884 8389580 8390304
#


and output of fdisk -l is:


# fdisk -l /dev/sda

Disk /dev/sda: 146.6 GB, 146694733824 bytes
255 heads, 63 sectors/track, 17834 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2102 16779892+ 82 Linux swap / Solaris
/dev/sda3 2103 4713 20972857+ 83 Linux
/dev/sda4 4714 17834 105394432+ 5 Extended
/dev/sda5 4714 6018 10482381 83 Linux
/dev/sda6 6019 7323 10482381 83 Linux
/dev/sda7 7324 8106 6289416 83 Linux
/dev/sda8 8107 8367 2096451 83 Linux
/dev/sda9 8368 8628 2096451 83 Linux
#

We can add some space space in the extended partition here.

My questions here are:

1- Does adding swap space solve the performance issue?

2- If yes, what will be steps involved in adding the swap space to this system?

3- Any other recommendations or thoughts?

Any help is highly appreciated.

6 REPLIES 6
Steven E. Protter
Exalted Contributor
Solution

Re: Swap space issue

Shalom,

1- Does adding swap space solve the performance issue?

If apps will not launch for inability to reserve swap space, adding swap will help. If there is actual paging going on (vmstat) then no swap space addition will not help. In the case of actual paging, either reduce the demand for memory or increase the supply.


2- If yes, what will be steps involved in adding the swap space to this system?

Add disk for swap, carve it up with fdisk
http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/sysadmin-guide/s1-swap-adding.html


3- Any other recommendations or thoughts?

More memory.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Waqar Razi
Regular Advisor

Re: Swap space issue

We have graphs of available swap space for a week and we have noticed that some times, the available free swap space reaches to 0. The application starts without any problem but they are having some performace issues. And from the research, it seems that available swap space some times reaches to zero.

Need your suggestion.

Thanks
Waqar Razi
Regular Advisor

Re: Swap space issue

Here is the output of vmstat:

# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 2254512 10682404 30412 146744 2 17 2 19 0 0 1 1 98 0 0
#
Tim Nelson
Honored Contributor

Re: Swap space issue

Wagar,

Your current stats do not show an issue but I will key off of the swap space comment.

If you run out of swap space then new processes cannot fork and will not run.

From your current stats this server has 16gb of physical ram of which the buffer cache has 1GB allocated ( this tells me that you have 1GB still available ), so currently no issue.

If you see swap space at zero I would allocate additional swap space using what is available on /dev/sda starting at cyl 8629 and up to cyl 17384.

Adding swap will NOT solve your performance issue. Once you start swapping ( aka running out of physical ram) performance will be poor.

You will need more RAM to solve that, adding swap space will solve the issue where processes cannot start due to lack of virtual memory..

Tim Nelson
Honored Contributor

Re: Swap space issue

sorry let me be more exact with the memory statement.

from this:
# free
total used free shared buffers cached
Mem: 16436856 16349104 87752 0 1912 1105768
-/+ buffers/cache: 15241424 1195432
Swap: 16779884 8389580 8390304


I see 16GB physical total.
877mb free and 1.1GB in cache.
The cache is dynamic and will give it up if needed.
so 877mb of free + 1.1GB of cache is currently available for process use. (~2GB available )

this is a snapshot in time, so right at that moment you were ok. need to review stats over time with sar, vmstat, etc...



Steven E. Protter
Exalted Contributor

Re: Swap space issue

Shalom,

I do not see paging going on.

The problem is likely from a lack of swap space available for reservation.

On a 16 GB system, I would start out at 50% of RAM as a start point for swap. This is a case where there is no penalty except lost disk space.

I just saw a 20 GB ram system here with 2 GB of swap. But process utilization is so low on that system it is not running into the same issues you are.

For a large memory system to operate at full memory utilization, the minimum amount of swap required is in my opinion 50% of RAM.

Since any process can be swapped to disk, the rule of thumb that might be safe is RAM=swap. This may seem like wasted disk space, but it is necessary.

In this instance I would strongly consider setting system swap space to between 50% and 100% of RAM.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com