Swap space myths on Unix systems – reference article for the new oracle dba





when i was searching google for more information about swap space , came across this great article explaining about the common myths that people have (may be new oracle dba’s) about swap space on unix servers.
Solaris FAQ: Myths and facts about Solaris swap space

As one of the 60 or so OS Ambassadors in Sun world wide, I frequently see the question asked about how to configure Solaris swap.  Apparently, there is quite a bit of mystery about swap space even though it is clearly documented in the Solaris administrator collection.  I decided to publish a collection of my favorite myths and facts about Solaris swap space.  Note that certain applications (such as Oracle) that use “Intimate Shared Memory” will require more swap than most applications. Please refer to the application docs for swap size recommendations.

Myth:  Always set Solaris swap to 2 x RAM size

This myth is clearly a case of users who have been around since the SunOS 4.x days.  Virtual memory today consists of the sum total of physical RAM and swap space on disk.  Solaris DOES NOT require any swap space to be configured at all.  If you choose this option, once RAM is full, you will not be able to start new processes.  There are recommendations for swap space size in the Solaris documentation but the rule of thumb in general is that swap should be configured about 30% of physical RAM. 

Myth: Solaris swap requires raw partitions to be available

Swap can easily be added using standard UFS files in addition to raw disk slice, online without a reboot.  The added swap space takes effect immediately.  The instructions are documented but because I’m a nice guy (and it is so easy) I’ll put an example here.

       mkfile 500m /swapfile

       swap -a /swapfile

       Make this added swap area persistent across reboots by adding a new entry in /etc/vfstab

There now, that didn’t hurt a bit did it?  The file can be any size you choose and any location in a UFS file system.  You can add as many swap files as you like. ZFS is not currently supported for swap files.  You can use the vmstat or swap commands to show the changes.  Swap space is used in a round robin rotation.

Myth: Swap partitions are also dump partitions

It was back in the Solaris 8 timeframe (late 1999) that the dumpadm command was added to Solaris. To quote the S8 documentation (because I’m lazy): The new dumpadm command, which allows system administrators to configure crash dumps of the operating system. The dumpadm configuration parameters include the dump content, dump device, and the directory in which crash dump files are saved.  See the Solaris 10 dumpadm documentation for more information.

Myth:  You can’t control swap space for Solaris 10 containers

 With the latest update of Solaris 10 08/07, we added new resource controls for swap space and containers.  These provide significantly better control and help eliminate denial of service attacks caused by memory leaks and “malloc bombs.”

       zone.max-locked-memory

       zone.max-msg-ids

       zone.max-sem-ids

       zone.max-shm-ids

       zone.max-shm-memory

       project.max-locked-memory – Replaces project.max-device-locked-memory

       zone.max-swap – Provides swap capping for zones through the capped-memory resource

Fact: Swap and tmpfs are the same

This is true.  This design has a number of benefits but we also offer a number of options for controlling tmpfs usage.  I’ll refer you directly to the documentation again. 

Fact:  Using swap is bad for performance

Think of swap space as an overflow area for RAM.  It’s OK if non-active processes are using swap space, however, if actively used processes are constantly having their pages moved back and forth from RAM to disk based swap areas, performance will suffer.  You can monitor this using the vmstat FREE column.  In Solaris 7 and earlier this number wass relatively meaningless.  Since Solaris 8, however, the FREE column provides an accurate indicator of your free memory.  If the number is too low, page scanning begins (as indicated by the ‘sr’ column in vmstat).  Any non-zero number in the ‘sr’ column for an extended period of time is an indicator that it’s time to buy more RAM. 

Jim Maura and Rich McDougall have written excellent books about Solaris Internals which described memory utilization in excruciating details.  See their Solaris Internals wiki for more FAQ and to purchase the books. 

 Why should you care?

Solaris continues to be updated and improved with every update based upon feedback from our customers.  If you are not staying up with the latest technology, you’re still “living in the 90s” and not getting the most from your compute resource.  We work hard to provide you the facilities in Solaris to increase your availability and utilization of you compute farms.

 

Author: admin