1834711 Members
2665 Online
110069 Solutions
New Discussion

Sizing swap

 
SOLVED
Go to solution
Lonny Balderston
Frequent Advisor

Sizing swap

There appear to be two schools of thought regarding sizing swap under HP-UX. 1: set swap to match RAM. 2: If you have a lot of RAM, keep swap small, like 1GB. What are the dis/advantages of each scheme?
11 REPLIES 11
Sundar_7
Honored Contributor

Re: Sizing swap

As far as I know, there is no disadvantage in keeping the swap size equal to the RAM size except for the $$$ you are going to spend on the disk space :-)
Learn What to do ,How to do and more importantly When to do ?
Geoff Wild
Honored Contributor

Re: Sizing swap

A lot of this depends on your application(s)...

If you want to be able to dump - then Primary swap should be 1 x memory.

Application - SAP - requires 24GB of swap...

Another thing I like to do is set /var/adm/crash - 1 x memory + 512MB

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Sizing swap

The primary advantage of smaller swap spaces is that you are not wasting disk space for something that you don't use --- that's why you bought all that RAM in the first place.

The idea is to never have to swap at all. If you enable pseudoswap then you can fully utilize your system with 25% of RAM as swap.

My typical setup on boxes with large amounts of RAM is to configure 1GB or so or primary swap and then monitor swap usage. It's so easy to add additional swap that it is really not worth worrying about. All swap should be mirrored so this means that whatever disk space you thought you were wasting just got doubled. For applications like SAP that require 3X memory for swap during installation, my answer to that is too configure filesystem swap at low priority. After the SAP install is done, you can then reduce swap to tiny values and SAP is still happy.

I am also a firm believer that swap and dump have nothing to do with one another.


If it ain't broke, I can fix that.
Steven E. Protter
Exalted Contributor

Re: Sizing swap

There are other schemes/schools as well.

I am a member(without invitation)in the A. Clay Stephenson school of swap.

Set a primary swap area to half of ram. Then set a lower priority one to make up the difference between that and 1.5 times RAM. The 1.5 is up to you.

This scheme provides excellent performance when system loads are light with the scalability of being able to handle higher loads.

Just setting swap to 2x RAM can impede performance when compared to other scenarios. To cover the swap area there are more and longer head movements on the disks. Whether that makes a huge impace with todays 10K and 15K disks is open to debate.

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
Chris Vail
Honored Contributor

Re: Sizing swap

This is a judgement call on the part of you, the systems administrator. To be very conservative, set swap AT LEAST as much as RAM--and a little more, perhaps as much as 1.5x as much as RAM. This allows you to catch a crash dump if necessary. In a true production environment, this is absolutely mandatory (because figuring out why it crashed and died is absolutely mandatory). In a development or test environment, especially on older/slower hardware, this is not as necessary. In these environments, if the system crashes, you just blame it on the end user and give a blank stare if they ask you for a crash dump analysis.

Otherwise, if its using 8GB of swap along with 8GB of RAM, the system is SERIOUSLY hurting. In fact, if this system is using even half a gigabyte of swap on a routine basis, your computer is hopelessly overworked. So the real answer to your question, like for most good questions, is "It all depends.....". In this case, it all depends on the use of the system and tolerance of error. The less error you can tolerate, the more swap the system will need.


Chris
Sorrel G. Jakins
Valued Contributor

Re: Sizing swap

Clay, I'm admittedly a bit slow, but would you care to elucidate "All swap should be mirrored"? I thought just the opposite. -sorrel
Patrick Wallek
Honored Contributor

Re: Sizing swap

Your swap DEFINITELY must be mirrored. If it is not, and the disk that has your swap area on it dies, thus making swap inaccessable, then you are screwed. Your machine will not function and may actually crash. When a process starts, it must be able to reserve swap space. If no swap space is there no processes will be able to start. If you mirror your root disk(s), go ahead and mirror the swap as well.

I think you may be confusing swap and dump. Dump space does not need to be mirrored as it is just used for crash dumps.
A. Clay Stephenson
Acclaimed Contributor

Re: Sizing swap

Well, it's normally considered a good thing to never need to shutdown except for planned maintenance. If a disk housing a swap space needs to be replaced and it's not mirrored then you must shutdown -- if the OS hasn't already failed anyway. I haven't shutdown a box to replace a failed disk in many years although I've replaced many, many disks over that period. The thing that I never mirror is dump space because that unlike swap is not a critical resource and can be dealt with during a scheduled maintenance window and I never want to ask myself "Now which mirror did the dump really get written to?"

If it ain't broke, I can fix that.
Todd McDaniel_1
Honored Contributor

Re: Sizing swap

Sorrel,

If swap is not mirrored. you may have problems when your boot disk fails and you have NO swap available for root...when you fail over to your alt boot path.

that is why you should have at least SOME of your total swap located in VG00 on the root bootable disk both PRI and ALT... so that it will be mirrored at least for the OS to have swap.

In some cases it will prevent you from being able to boot with out swap being mirrored.


---------------------------------------------------
All my swap areas are mirrored whether on vg00 or vg01. And my swap is typically half of Memory unless the box has large amount of Memory...In one case 72GB memory with 26GB Swap

Unix, the other white meat.
Geoff Wild
Honored Contributor

Re: Sizing swap

Clay and Patrick are right - you need to mirror swap - just in case you lose a disk - if the one that had swap on is gone - and something was reserved in swap - your machine will crash - this is a recommendation from HP - just can't find the doc...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Todd McDaniel_1
Honored Contributor

Re: Sizing swap

One more thing.

It is also recommended that you have a separate DUMP area from SWAP so that if you need to reboot or your box reboots on a panic, you dont lose the dump...

If your dump is the same as swap you can risk losing a dump that could be crucial to a solution.
Unix, the other white meat.