Enterprise Software

Tune your swap file to optimize your NetWare server's performance

Swap files are common on Windows servers; however, NetWare administrators haven't had to worry about them until NetWare 5 came along. John Sheesley explains how NetWare uses swap files and how to tweak them for better server performance.


Where Windows has always used swap files as temporary memory storage when a server's hard drive runs out of RAM, NetWare versions prior to 5.0 didn't support them. However, NetWare versions 5.0 and later do support swap files, and with a bit of information and some tweaking, you can tune them to increase the performance and stability of your server. In this Daily Drill Down, I will explain how later NetWare versions use swap files and how you can use the SWAP command to view swap-file information and adjust the file's parameters.

How NetWare uses swap files
In NetWare, swap files work basically the same way they do in other OSs. When you start a new program, NetWare checks the available memory on the server to see if there’s enough RAM free to run it. If the server runs out of RAM to run programs, it will temporarily take a program in RAM that's not currently active and store it to a temporary area on the server’s hard drive. Then, it will load and run the program that didn’t initially fit. If NetWare determines that the swapped out program needs to run for some reason, it will swap another program out and reload the swapped program.

In earlier versions of NetWare, swap files weren’t used. If your server didn’t have enough RAM to run a program, you were out of luck. However, there were several good points to not having swap files.

First, using swap files can slow down a server. As fast as computers are, swapping programs temporarily on and off a hard disk is much slower than just running them in RAM. The extra disk overhead can also slow down other disk operations such as users reading and writing data files.

Second, swap files can consume valuable disk space. Windows administrators usually go by the rule of creating swap-file sizes two and a half times the size of the RAM. So, if your server has 256 MB of RAM, you can lose a half a gigabyte of potential storage space to a swap file. NetWare 5.x swap files start at 2 MB in size and can grow to consume all of the free space on your NetWare volume, possibly multiple gigabytes, and that’s space your users can’t use to store data files.

Finally, swap files can introduce instability to an OS. NetWare 3.x's and NetWare 4.x’s memory architecture was very stable. The OSs carefully loaded NLMs into memory and once there, the NLMs almost never changed memory addresses. Programs that are swapped in and out obtain new memory addresses every time they move to and from the disk, which can cause confusion with memory pointers in the programs. And, as you can guess, if the program can’t reference a given memory address, problems occur. The program will invariably crash, potentially causing you to lose data or to have to restart your server. Windows administrators are used to this when they see the Blue Screen of Death.

So if swap files are so bad, why did Novell introduce them into NetWare? The main reason was to overcome the memory limitations of servers, since NetWare had become more widely used to serve applications. Application servers use memory more heavily than a server doing only file and print functions. Novell’s traditional stable approach would cause applications to quickly run out of memory as applications loaded and unloaded.

In current NetWare OSs, Novell takes a very conservative approach to swap-file usage. NetWare will only swap out programs running protected memory addresses, which includes all Java programs. This ensures that no vital system programs are accidentally swapped out. By default, most NLMs—even nonsystem ones such as the NLMs that run GroupWise—run in unprotected space. If you want to make an NLM swappable, you can do so by using the load protected NLMname command from the server console prompt where NLMname stands for the name of the NLM that you execute.

Viewing swap-file information
By default, NetWare places the swap file on the SYS volume of your server. You can view swap-file information about your server by using Monitor or by using the SWAP command from your server’s console prompt.

Viewing information from Monitor is often easier because you are probably already running Monitor to monitor conditions on your server. Monitor’s information is also laid out better than the output from the SWAP command.

To view swap-file information in Monitor, select Virtual Memory from the Available Options menu. When the Virtual Memory Options menu appears, select Swap Files and press [Enter]. You’ll then see the Swap Files screen shown in Figure A.

Figure A
Monitor can display information about your server's swap file.


As you can see in the figure, my test server has one swap file located on the SYS volume. Monitor expresses the values for swap-file information in terms of kilobytes (KB). This server has a swap-file size of a little over 6 MB, or 6,784 KB.

If you look at the Free Swap File Space and Used Swap File Space, you’ll notice that the server isn’t using all of the space allocated for a swap file. Like Windows, NetWare dynamically enlarges and contracts the size of a swap file. However, NetWare doesn’t contract a swap file as quickly as it will enlarge it. If the space is unused and no longer needed, NetWare will retain the size of the swap file for a while in case it’s needed again. Over time, NetWare will reduce the size of the swap file, returning the space for use as data-file storage.

The Minimum Swap File Size and Maximum Swap File Size fields display exactly what the label says, the minimum and maximum swap-file sizes. By default, the minimum file size for a swap file is 2 MB. It can grow as large as the entire volume if you wish, but the default maximum swap-file size is 2 GB.

The last field is Minimum Free Per Volume. This field displays the minimum amount of space that NetWare will allow to be free on the volume when expanding a swap file. For example, if you have a 1-GB SYS volume with 750 MB of space already taken and a Minimum Free Per Volume limit of 5 MB, even if you’ve specified a maximum swap-file size of 500 MB, NetWare won’t allow the swap file to grow larger than 245 MB. This ensures that you don’t completely fill a volume with a swap file, because completely filling up a SYS volume can lead to system crashes and data loss.

Using the SWAP command
Another way to find out information about your swap file is by using the SWAP command. Go to your server’s console prompt, type swap, and press [Enter]. When you do, you’ll see the screen shown in Figure B.

Figure B
The SWAP command can also display swap-file information.


As you can see, the SWAP command presents the same information but in a slightly less friendly format. One nice thing it does, however, is express the data displayed in terms of megabytes and not kilobytes. One thing you may find confusing is the screen's repetitiveness. Although the Volume Name and Summary information lines may seem redundant, they aren’t necessarily. On my test server, there’s only one swap file on one volume. If there were a swap file on the VOL1 volume, that information would be displayed in another section with the Summary fields totaling the values for both SYS and VOL1.

In the Swap File column, you’ll notice that the SWAP command doesn’t give as much detail as Monitor. The key difference is that SWAP shows you the current size of the swap file and how much is used but not how much space is available in the swap file. However, you have to do only a little bit of math to figure that out for yourself.

Conversely, in the Volume column, the SWAP command gives a little more detail than Monitor does. For example, you can see the total size of the volume, but you can also see the total amount of space free on the volume (604 MB). This can be handy to see when viewing the swap-file information to see just how close you are to running out of space on the volume. If you’re too close, you can manually adjust the size of the swap file.

Tuning the swap file with the SWAP command
The SWAP command does more than just display swap-file information. You can also adjust swap-file parameters with it by using some of its command-line switches. The complete syntax for the SWAP command is SWAP [ADD vol [parameter = value]] [DEL vol] [PARAMETER vol parameter = value]. Parameters you can use include:
  • MIN, which is the minimum size of the swap file. If not specified, the default value is 2 MB.
  • MAX, which is the maximum size of the swap file. If not specified, the default value is the maximum amount of space on the volume.
  • MIN FREE, which is the minimum amount of space to leave free on the volume. If not specified, the default value is 5 MB.

For example, if you wanted to add an additional swap file on the VOL1 volume with a maximum size of 1 GB and a minimum size of 50 MB, you’d type SWAP ADD VOL1 MIN=50 MAX=1000.

There are a few things you should take into consideration when adding swap-file usage. First, you can only create one swap file per volume. NetWare creates the swap file on the SYS volume by default, but you can delete it if you want. Also, you can add a swap file to a volume even if the volume is not mounted. After you mount the volume, the file will become available. When adding a swap file, you should place swap files on the fastest volume or on the one with the most free space.

When you create a swap file on a different volume, it’s not permanent. If you shut down your server, NetWare deletes all swap files on its volumes. When it restarts, it automatically re-creates only the swap file on the SYS volume. You will then need to manually enter the SWAP commands necessary to reconfigure your server the way you want. You can also edit your server’s AUTOEXEC.NCF file to automatically create swap files by entering the appropriate SWAP commands there.

If you have multiple swap files, you don’t have to worry about telling NetWare which swap file to use. NetWare will just pick and choose automatically as needed.

You can delete swap files by using the SWAP DEL vol command where you replace vol with the name of the volume you want to delete. When you delete a swap file, NetWare moves any data in the swap file to another swap file. If you try to delete a swap file but haven’t previously created an alternate swap file on another volume, NetWare will display an error message. To make sure the server doesn’t become unstable, it will not delete the swap file.

Conclusion
Swap files are common on Windows systems but aren’t something that NetWare administrators have traditionally had to worry about. As a NetWare administrator, you must learn a few new tricks to deal with swap files effectively on your NetWare 5.x and 6 servers. Once you understand how they work and the commands needed to tune them, you can increase performance and stability on your system.

Editor's Picks