Using the Results
Using performance data to diagnose a software problem is an important engineering skill and a prerequisite for determining how to fix performance problems (e.g., making code changes, changing server settings). For an in-depth discussion of troubleshooting performance problems, see "Troubleshooting High CPU Utilization" (February 2002, http://www.windowswebsolutions.com, InstantDoc ID 23574). I concentrate here on some of the server settings you can change. Be sure to test any changes to ensure that they don't decrease your production system's performance.
IIS metabase settings. You can tune your Web servers by adjusting the following performance settings in the metabase. (Note that this is only a partial list of values that you can set.)
- AspThreadGateEnabled (not available in IIS 4.0 and earlier)This setting, if enabled, turns on the ASP thread gate, which dynamically monitors and modifies the number of worker threads that each dllhost.exe uses to handle incoming ASP requests. The feature compares CPU usage with set thresholds (AspThreadGateLoadLow and AspThreadGateLoadHigh) and adjusts the number of threads that the system permits to execute. Modify this setting if you notice that your server is queuing ASP requests or that ASP requests are causing CPU usage greater than 80 percent.
- AspProcessorThreadMax (ProcessorThreadMax in IIS 4.0)This setting limits the number of worker threads that IIS will allow for ASP request handling. This number is different for each process, so each process has an ASP worker thread pool. The default value is 25 threads per processor. Although ASP thread-gating functionality uses this setting, thread gating doesn't need to be enabled for the setting to work. One situation in which you might want to use this setting without thread gating enabled is if you notice a lot of backed-up requests and you know that none of the requests use CPU power (e.g., they're on a back-end database).
- AspScriptEngineCacheMaxThis value sets the number of ASP script engines to cache in memory. ASP script engines turn a parsed script into byte code. In IIS 5.0, the default value is 125. In IIS 4.0, the default value is 30. If your site has thousands of ASP pages, you can probably improve performance by increasing the default value.
- AspScriptFileCacheSizeThis setting adjusts the number of parsed ASP scripts to keep in memory. The default value is 250. If you set this value to 0, no scripts are cached; if you set it to -1, all scripts are cached.
- ConnectionTimeoutThis setting lets you set the amount of time before IIS terminates an inactive connection. The default value is 900 seconds (15 minutes). If you habitually run out of connections on the server, try decreasing this value. If your site has a page that takes a long time to return and you don't have a lot of traffic on the server, you can increase this number. Be sure that you don't increase this value to the point that your server runs out of connections when it reaches peak load.
- MaxEndpointConnectionsThis value sets the maximum number of listeners that will be available on any given network endpoint (e.g., port 80). The default value is 100. If clients often get a Server Too Busy error on a heavily used site but they can connect successfully after only one or two refreshes, you might need to increase this number (along with the ServerListenBacklog value).
- ServerListenBacklogThis setting adjusts the number of outstanding sockets that your Web server can queue. The default value is based on the ServerSize setting. If ServerSize is set to 0, the default number of sockets is 5; if ServerSize is 1, the default number is 40; and if ServerSize is 2, the default number is 100. The lesser of the ServerListenBacklog value and MaxEndpointConnections value is used to determine how many connections are pooled on your server.
- ServerSizeThis setting shows the approximate number of requests per day you expect to receive. A value of 0 indicates fewer than 10,000 requests per day; 1 indicates fewer than 100,000 per day; and 2 indicates more than 100,000 per day. You can set this value in the Internet Service Manager (ISM) console's Performance Tuning slider.
Registry settings. The following registry settings can affect your site's performance. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\InetInfo\Parameters subkey and check the following values:
- MaxPoolThreadsThis value indicates the maximum number of threads created to handle incoming static requests. The default value is four per processor. If your cache settings are adequate for your Web traffic, you shouldn't need to tweak this value.
- PoolThreadLimitThis value overrides the MaxPoolThreads value for requests to ISAPI Extensions and to other services in Inetinfo (e.g., FTP, SMTP). The default value is two times the number of megabytes of RAM in the system (with a maximum default value of 256). Because threads in the IIS thread pool exist for only 24 hours, you usually don't need to change this number unless you see a great deal of context switching, in which case you might want to decrease this setting.
Know Your Systems
Keep in mind that careful observation and testing of your Web server systems, as well as a basic understanding of what's happening on these systems, are key to optimizing performance. If your system is running slowly, determine the reason before you start changing settings, or you might make the system slower. If you use common sense and good troubleshooting techniques, you'll be able to keep your systems finely tuned.