Swapping out in Emergencies

By Paul Murphy, author of The Unix Guide to Defenestration

You see a lot of serious Unix people talking about reducing swap/paging space to a typical 512MB ragardless of what the real memory is. Don't apply that rule without careful thought: remember, even mirrored, the cost of swap only runs about $50/GB and there are lots of uses for a fast file system that go beyond simple swap or paging.

Keeping swap space small relative to real memory is usually good advice for a large machine with a well understood workload but terrible advice for a small machine running a mixed or unpredictable workload. For example, if you're responsible for a 6800 running Oracle in 96GB of RAM, your memory usage will be predictable down to the megabyte and you'll have no use for 192GB of parking space. If, on the other hand, you're supporting email users on a 250 with 2GB of installed RAM, having 4GB of available process parking will eventually make the difference between normal operation and a parade of users going in to see the boss - and closing the door behind them.

For swap, along with everything else, I generally prefer simple internal storage without software mediated mirroring, but there are two exceptions:

  1. for larger machines like a V880 or better it can be worthwhile to transfer boot, dump, and swap, and all the other systems functions to something like the Sun 3310 SCSI array. This has separate power, up to 512MB cache, and does RAID 0+1 (striping for speed, and mirroring for redundancy) using its own CPU. It's relatively expensive, but you get a lot of speed and redundancy benefits without burdening your processors or using up internal space.

  2. on small, but truly critical, machines, like the company RADIUS server, it makes sense to put up with the pain and overheads associated with software mirroring to mirror the boot disk, including its swap space.

In all three cases, though, think carefully about workload and costs before committing to a configuration because, somewhere downstream, a few extra gigs of swap could save you from a stressful 3AM call in or a long struggle to maintain performance on an overloaded machine.

Two notes:

  1. if it's not your machine and you don't know whether the last guy installed mirroring, check /etc/vstab and vfstab.bak first. If the current or former mount point for / looks like /dev/md/dsk rather than /dev/dsk; assume someone's at least tried to set up boot mirroring using Disksuite.

  2. if you're using some form of mirroring on standard UFS filesystems, it's a good idea to turn on logging - see (man mount_ufs) as this turns ufs into a journaled file system and thereby enables fast recovery in case of a reboot from the mirror.