General
cancel
Showing results for 
Search instead for 
Did you mean: 

How much of a swap file do you need??

SOLVED
Go to solution
Ian Derringer
Regular Advisor

How much of a swap file do you need??

Hi,
I am getting ready to setup a Itanium RX4640 4x1.5Ghz and 16GB of RAM running RH Linux AS 3.0 - I know rule of the thumb is that you must create a swap file that's double the size of your RAM. So, if I have 16GB of RAM then I should create a 32GB of swap file, correct? By the way, I will also have Oracle 10g running on this server as well. I believe Oracle usually like to set the SGA higher than most, therefore, it uses more memory then the swap disk.

Can someone direct me to the right direction?

Thank you in advance.
Ian
15 REPLIES
Vitaly Karasik_1
Honored Contributor
Solution

Re: How much of a swap file do you need??

As far as I remember, you should create just 2GB swap partition, not more.

Check RHEL installation manual for more.
Srikanth A_1
Occasional Advisor

Re: How much of a swap file do you need??

SWAP thumb rules is 2 times of mem
guess even with oracle 2 times of mem will do
Huc_1
Honored Contributor

Re: How much of a swap file do you need??

I think the following information is still valid with newer version of oracle.

http://www.puschitz.com/TuningLinuxForOracle.shtml#SizingSwapSpace

J-P Huc
Smile I will feel the difference
Wim Van den Wyngaert
Honored Contributor

Re: How much of a swap file do you need??

I wouldn't give a lot to systems with 16GB.

On systems with a few hundred MB of memory yes, because most applications simply don't have enough with that.

If you are trying to use the complete physical memory, you can should use a swap space of let's say 4 GB. Just as an overflow area when things go wrong (programs allocating more memory than normal). When you have thousands of sessions on your system, it may be a good thing to have a lot of swap space (for parking non-active user).

Wim
Wim
Stuart Browne
Honored Contributor

Re: How much of a swap file do you need??

When you're using that amount of RAM, I guess the rule gets relaxed a bit, but i like to have at least the same amount of swap as I have physical memory.

Espeically with the Enterprise based distributions which include the ability to send memory dumps upon crash to swap for diagnosis.

If you've got the disk space of course ;)
One long-haired git at your service...
Steven E. Protter
Exalted Contributor

Re: How much of a swap file do you need??

On larger HP Integrity systems with lots of RAM, say 16 GB, you do not need to have 16 GB of swap. 8 GB is probably enough.

This however depends on use. If push the system hard and have lots of swap reservervation or actual swap use,you will need more swap.

Once there is not enough swap left for a process to reserve swap, even if there is no actual paging, the process will fail to start and indicate in the error message that the system has unsufficient 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
dirk dierickx
Honored Contributor

Re: How much of a swap file do you need??

swap size, a debate that has been going on since it got invented. one conclusion is that there is no 1 rule fits all. depending what you are doing with your system, the rules change.

according to the redhat oracle 9i deployment guide it says swap should be 2x ram with a minimum of 1024MB.

i would go with red hats recommendations.
Andrew Cowan
Honored Contributor

Re: How much of a swap file do you need??

If you create a very large swap/paging file the system will have to devote a sizeable amount of time to managing it. If you absolutely must have this much, try splitting it evenly amongst several disks and volume groups, and try to pick the least busy ones.

There did used to be a physical limit on the swap size of 2Gb, and as far as I know this was originally due to a filesystem limitation (on size of an idividual file). RHAS-2.1 quotes a max of 6 X 2GB, but I cannot find anything for RHAS 3.x so I would expect it to be the same.

I would suggest creating several equal sized files e.g. 4 x 1Gb and then monitor how much Oracle is actually using, then you can always add more later. This is always dependant on the number of disks you havve.

On IBM/AIX they say that you should have one realtively small paging area that is large enough to boot-up etc, and then several other equally large paging spaces on other disks, and in other volume groups. I've never tried this, but think that it should work just as well for LInux.
Wim Van den Wyngaert
Honored Contributor

Re: How much of a swap file do you need??

I'm actually a VMS man and don't know the details of Linux Swapping but consider :

1) is linux able to move a process from one file to another when swap space is full or will the process simply abort ?

2) will processes be distributed over the different swap files or is e.g. the 2nd only used when the first one is full ?

3) what performance will an oracle server get when his virtual memory is outswapped ? E.g. if you do a join of 1 M row it might have to do 1 M swap-in-out to get the correct data. Will Linux find another victem with less activity ?

Wim
Wim
Stuart Browne
Honored Contributor

Re: How much of a swap file do you need??

Wow.. The swap behaviour of linux is pretty advanced.

Generally it will only swap out inactive processes.

If everything is active, then it's oldest segments.

It's best to use swap-file-systems instead of swap-file's for better performance.

You might want to read through the kernel-source documentation (/usr/share/doc/kernel-doc-*/vm/* in paricular), as well as the man pages for 'mkswap'.
One long-haired git at your service...
Andrew Cowan
Honored Contributor

Re: How much of a swap file do you need??

It's worth noting that Unix/Linux detects multiple swap/paging spaces and attempts to stripe data across them. This is designed not for resillience, but for performance, and if working correctly, balances IO. This is why your paging spaces should normally be of equal size. The one sin that you must NEVER commit is to place two or more paging areas on the same physical disk as your IO will go through the roof, and your performance in the direction of the toilet!
Wim Van den Wyngaert
Honored Contributor

Re: How much of a swap file do you need??

Good to read and know :
http://www.fiveanddime.net/ss/swap.htm

Wim
Wim
Stuart Browne
Honored Contributor

Re: How much of a swap file do you need??

(please note that the limits in that URL are based off of 2.2 kernels, not modern 2.4 or 2.6 kernels).
One long-haired git at your service...
Wim Van den Wyngaert
Honored Contributor

Re: How much of a swap file do you need??

Did some testing with RH kernel 2.6 on Alpha without a swap file to see how Linux reacts.

I was trying to eat all memory by executing script wim which contains :
sleep 1
bash wim

As a normal user : when free mem is 4 MB, the message "Resource temporarily unavailable" is given. Memory cache + buffers was hardly reduced in size. System cpu usage increased up to 7%.

As root : at 4 MB, the memory + buffer cache was slowly deactivated, consuming about 10% in system mode in the beginning, 90% system mode at the end. When it reached 2 MB memory cache, it started taking the 4 MB free memory. Then my telnet was aborted.

I restarted directly on the console to see how it ends. This time, a lot less system mode cpu was used (???). About 10%. But the script needed 15 seconds for 1 execution (when cache + buf were only a few MB).
When the cache reached 1 MB, it started doing something else. I guess pages were taken from processes because the buf + cache counter increased again. Script execution took already 1 min. Then oit started eating the 4 MB free memory but finally the session was killed.

In /var/log/messages I found "out of memory : killed process xxx".

The machine is still running.

What I find strange is that a normal user is refused memory while there is still a lot of cache that could be removed.

Wim
Wim
Wim Van den Wyngaert
Honored Contributor

Re: How much of a swap file do you need??

Same test with a swap file of 200 MB.
Ended with "too many open files" when swpd of vmstat reached 80 MB.

Wim
Wim