Optimizing Memory Usage

Applies To: Windows Server 2003, Windows Server 2003 with SP1

Servers running IIS 6.0 benefit from ample physical memory. Generally, the more memory that you add, the more the servers use and the better they perform. IIS 6.0 requires a minimum of 128 MB of memory; at least 256 MB is recommended. If you are running memory-intensive applications, your server might require much more memory to run optimally — more than the recommended 256 MB of memory.

Adding RAM to your system is not the only option, however. The following methods can be used to optimize memory performance without adding memory.

Improve Data Organization

To improve the performance of the file system cache, keep related Web files on the same logical partitions of a disk.

Use Disk Defragmenter to consolidate fragmented files and folders on the server's hard disk so that each occupies a single, contiguous space on the volume. As a result, the system can gain access to files and folders and save new ones more efficiently.

Increase the Efficiency of High-Traffic Web Sites

Evaluate your high-traffic Web sites to find ways to increase their efficiency. For more information about creating efficient Web sites, see Creating a More Efficient Web Site.

Try Disk Mirroring or Striping

The optimum configuration is to have enough physical memory to hold all static Web pages. However, if pages must be retrieved from disk, use mirroring or striping to make reading from disk sets faster. In some cases, a caching disk controller is helpful. For more information about mirrored or striped volumes, see "Using mirrored volumes" or "Using striped volumes" in Help and Support Center for Windows Server 2003.

Add or Enlarge Paging Files

Add paging files, or increase the size of existing ones. Windows Server 2003 creates one paging file on the system disk, but you can also create a new paging file on each logical partition of each disk. By striping a paging file across separate physical drives, you can improve paging file performance by using drives that do not contain your sites content or log files.

You can change the sizes of existing paging files. The larger the paging file, the more memory the system commits to it. Be sure that the paging file on the system drive is at least twice the size of the physical memory, so that the system can write the entire contents of RAM to disk if the system unexpectedly locks up or shuts down.

For information about resizing paging files, see "Change the size of the virtual memory paging file" in Help and Support Center for Windows Server 2003.

Retime the IIS Object Cache

Consider shortening the period of time that an unused object remains in the cache, or lengthening the time that a used object remains in the cache, by adding the ObjectCacheTTL entry to the registry.

Warning

Do not edit the registry unless you have no alternative. The registry editor bypasses standard safeguards, allowing settings that can damage your system, or even require you to reinstall Windows. If you must edit the registry, back it up first and see IIS 6.0 Registry Reference.

The value of ObjectCacheTTL controls the static file cache by specifying the Time To Live (TTL), which sets the length of time that objects are held in cached memory. If an object in the memory cache has not been referenced for the defined period, that object is phased out of the cache.

The default value is 30 seconds. If system memory is limited or if the contents of the server are dynamic, you can use a lower TTL to prevent system memory from being used to cache a large number of volatile objects. Setting the ObjectCacheTTL entry to unlimited disables the object-cache scavenger and allows cached objects to remain in the cache until the cached object changes. Disabling the cache scavenger is useful if your server has ample system memory and your data is relatively static.

For more information about setting the time limit for the object cache, see Setting the IIS Object Cache Time Period.

Change the Balance of the File System Cache to the IIS 6.0 Working Set

By default, servers running Windows Server 2003 are configured to give preference to the file system cache over the working sets of processes when allocating memory (through the server property Maximize data throughput for file sharing). Although IIS 6.0–based servers benefit from a large file system cache, giving the file system cache preference often causes the IIS 6.0 pageable code to be written to disk, which results in lengthy processing delays. To avoid these processing delays, you can set server properties to maximize data throughput for network applications. For more information about setting the server properties to maximize throughput, see Maximizing Data Throughput for Network Applications.

Limit Connections

If your server does not have enough memory, limiting the number of connections on the server might help alleviate the shortage because some physical memory (about 10 KB per connection) is consumed by the data structures that the system uses to keep track of connections. For more information about limiting connections to save memory, see Limiting Connections to Manage Resources.

Limit the Queue Length for Application Pools

If you are running your server in worker process isolation mode, you can limit application pool queue lengths to prevent large numbers of requests from queuing up and overloading your server. When the queue length limits feature is enabled (it is enabled by default), IIS monitors the number of requests in a designated application pool queue before queuing a new request. Use IIS Manager to change the default limit of 1,000 requests for application pool request queues.

If adding a new request to the queue exceeds the maximum queue length, the server rejects the request and sends a 503 error (Server Too Busy) to the client. However, requests that are already queued remain queued even if the limit is changed to a value that is less than the current queue length.

For information about changing the queue length limit for an application pool by using IIS Manager, see Configuring Application Pool Queue-Length Limits. For information about configuring application pool queue length limits by using metabase properties, see the AppPoolQueueLength property in the Metabase Property Reference.

Adjust Resource Allocation in Windows

System processing is managed by Windows Server 2003, which can allocate processor and memory resources among tasks. If your server needs a temporary performance boost, you can temporarily adjust resource allocation in Windows to allocate the resources where you need them:

  • To obtain a faster response time, you can set Windows to allocate more processor time to the program that you are currently running.

  • If you want to run background programs, such as printing or disk backup, while you work, you can have Windows share processor resources equally between background and foreground programs.

For more information about changing the way that Windows allocates processor resources, see Change the performance of foreground and background programs in Help and Support Center for Windows Server 2003.

Limit Performance Logging

Always keep in mind that performance logging uses system resources. When you are not actively checking performance, disable performance-related logging to squeeze a bit more performance from your server.