Article ID: 305313 - View products that this article applies to.
This article was previously published under Q305313
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
The information covered in this article is provided by: Microsoft Press
This article explains how to optimize Microsoft Internet Information Services 5.0. This information is based on information that is a compilation of information from the Internet Information Services Resource Guide book in the Microsoft Windows 2000 Server Resource Kit
(http://www.microsoft.com/mspress/books/1394.asp), Chapter 4: "Capacity Planning" and Chapter 5: "Monitoring and Tuning Your Server." Learn More About Windows 2000 Server Resource Kit
How do you get the best performance from your Web site? If you're managing Web sites and applications running on Microsoft Windows 2000 Server and Internet Information Services 5.0, you've got the basic ingredients for a high-powered site that can handle thousands of concurrent transactions. But just because the platform is great, you don't necessarily get high performance. If any of the following problems are yours-your users are telling you their connections to your site are slow, your machines hang indefinitely in the middle of serving page requests, or you find yourself looking at vendor estimates for servers with more processing power and memory-you need to know first what factors affect the performance of your site and how to optimize IIS 5.0 for maximum throughput.
In this article, we'll see how IIS 5.0 uses system resources and how we can tune it for better performance. You'll find more information about this topic in the Microsoft Press book, Microsoft Internet Information Services 5.0 Resource Guide, which is one volume in the Microsoft Windows 2000 Server Resource Kit
(http://www.microsoft.com/mspress/books/1394.asp). This volume shows you in detail how to make the adjustments you need to make your Web site the best performer it can be. But we'll give you enough here to get started.
Sources of Poor Web Site PerformanceWhat makes a Web site slow? You'll get a lot of answers to that question, but they all boil down to just a few probable causes:
Optimizing Your ServerOptimizing the performance of your Web server basically requires that you figure out the optimal configuration of memory, processor, hard disk, and network I/O. Although you might think that in all cases, more is always better, the truth is more complex than that.
MemoryWant to optimize your server? Just add more memory! Isn't that what everyone says? If you've got a performance problem, just adding more RAM should fix it, right? If that were the case, I could end this article now. The truth is that, up to a point, adding memory does help; in fact, many cases of what seem to be processor or disk bottlenecks are actually memory problems. But beyond that point, adding memory does you no good at all. Still, optimizing your memory is the first and often easiest way to increase your IIS performance.
It's important to remember that IIS runs on Windows 2000 Server and inherits its memory management. That means that quite a bit of memory optimization goes on automatically. Windows 2000 Server adjusts the amount of memory available to processes and threads; it also adjusts the size of caches, paged and nonpaged memory pools, and the size of paging files to provide for optimum performance. When you optimize your memory for IIS, you're not so much trying to select the amount of memory to assign each process, thread, or cache as determining whether Windows 2000 has enough memory at its disposal to do all the automatic adjusting of which it's capable.
How do you find out whether your server has enough memory? Let's start by considering what an IIS 5.0 Web server uses its memory for. Windows 2000 Server controls memory by allocating to each process a corresponding chunk of memory known as its working set. In nearly all cases, individual threads within a process use pieces of memory allocated from within that working set. As a process grows, Windows 2000 adds more memory to its working set to account for its needs. Most of the memory allocated is pageable, which means the data in that memory can be stored temporarily on disk and recalled to RAM when it's needed. However, some threads, such as TCP/IP connections, require nonpageable memory; the memory must be live RAM, not a file on disk. As the number of connections increases and as other demands on nonpageable memory accrue, the system can run out of free memory and can't allocate any more. This situation can cause a system crash; in fact, it's how some denial-of-service attacks work.
IIS 5.0, like anything else running on a Windows 2000 Server, is a process: inetinfo.exe. Therefore, it has a working set. The working set that belongs to IIS includes space for the program code itself, active TCP/IP connections, the IIS Object Cache, the IIS log files, and HTTP connection data structures. The program code can occupy up to 2.5 MB of RAM, and the other elements of the working set vary in size according to how many users are simultaneously connected (about 10 KB for each TCP/IP connection, plus more for the HTTP data) and how many Web sites are being hosted on the server (minimum 64-KB memory-mapped log file per site). In addition to the working set of inetinfo.exe itself, IIS uses the IIS Template Cache, the IIS Script Engine Cache, and the IIS File System Cache, three caches that by default are outside inetinfo.exe, but can be configured to run within it. IIS also uses the TCP Transmission Control Block hash table and a pool of threads for executing code. These elements, which are external to inetinfo.exe, must live in nonpaged memory; you absolutely need enough RAM to accommodate them.
You can use the available counters in Performance Monitor to track the memory used by the system as well as by inetinfo.exe itself. Chapter 5 of The IIS 5.0 Resource Guide, "Monitoring and Tuning Your Server," includes an extensive list of counters. Some of the most essential are the following:
ProcessorAfter you get your memory optimized, you'll probably find that things work considerably faster. But you can do more: the processor is another potential bottleneck. The reason you work on optimizing memory first, though, is precisely so that you won't mistake memory problems for processor problems. For instance, if your server hasn't enough memory, it could spend lots of time paging threads to disk; that paging time adds to the processor load and can make it appear that an overloaded processor is the root of your difficulties.
Here again, Performance Monitor can tell you what you need to know. While there are several counters worth monitoring (again, see Chapter 5 of The Resource Guide), the most critical one is System\ Processor Queue Length. This counter tells you how many threads are waiting for the processor to become available. If this counter runs higher than 2 for extended lengths of time, your processor might be bottlenecked.
With multiprocessor servers, which are increasingly the norm, you've got another dimension to consider: processor load balancing. A system in which one processor is 100 percent booked while other processors sit idle is still bottlenecked, even though the System\% Processor Time counter reads lower, because that counter records the average value for all processors in the system by default. To get a good picture, you must run System\% Processor Time for each individual processor.
If your testing determines that you have a processor problem, your first option, of course, is to upgrade your processor or switch to a multiprocessor machine. If you do upgrade your processor, make sure it has the maximum L2 cache; IIS benefits from this because many of its instruction paths involve multiple components, which will run much faster in cache memory. The IIS 5.0 Resource Guide gives you several more pointers for optimizing your processor.
Hard DiskYou can do a number of things to your server's hard disk configuration to make disk use more efficient. Because the hard disk is the repository for paged memory, the way the server handles paging files becomes an important consideration. Let's go over this and other pointers:
Server Configuration OptionsBeyond the hardware optimizations, the configuration of the server software can have a dramatic impact on performance. Here, the name of the game is "stripped down for speed." You'll get good guidance on this topic from the Microsoft Windows 2000 Server and IIS 5.0 Administrator's Pocket Consultant
(http://www.microsoft.com/mspress/books/4364.asp), a very good quick reference from Microsoft Press. Is your Web server dedicated to IIS and nothing else? If not, that's something to fix. If you're trying to use your Web server for other network services, don't. Put those services on another machine and dedicate your IIS server to nothing but the Web. Once you do, here's a bunch of services you can most likely quit running on that machine:
You can make other optimizations to your server's configuration as well. For instance, IIS 5.0 uses up to 50 percent of your server's memory by default. This default setting allows you to accommodate any other applications you might need to run on the server. If you're dedicating the server to IIS and stripping out unnecessary services, however, you can certainly increase this percentage by creating and setting the MemCacheSize entry in the Windows Registry. Another setting you can adjust is the Server Optimization properties under File and Printer Sharing: set this to "Maximize throughput for network applications" and the server will preferentially keep inetinfo.exe in RAM rather than paging it out to disk when the File System Cache needs more space. Yet another setting that you can adjust is the maximum connection queue length for HTTP keep-alives; by exceeding the default setting of 15, you can extend the number of clients who can maintain open HTTP connections on your server between sessions, thus helping to reduce the number of new connections that must be generated. Both the Resource Guide
(http://www.microsoft.com/mspress/books/1394.asp)and the Administrator's Pocket Consultant
(http://www.microsoft.com/mspress/books/4364.asp)include more system settings you can adjust to optimize your configuration.
NOTE: If the IIS server is a member of a domain, the TCP/IP NetBIOS Helper service is required to properly apply group policy to the computer.
Optimizing Network BandwidthI won't say too much about optimizing network I/O because the reality is that most organizations buy all the bandwidth they can afford; everyone understands that the more bandwidth you've got, the more clients your Web site can serve. Most of the time, bandwidth is a sizable ongoing expense that becomes a budget issue beyond your control. You should know, however, that The Resource Guide includes substantial information about how to use Performance Monitor to keep track of your Web site's network bandwidth usage. Analyzing how well your server is using its available bandwidth can tell you whether you need to purchase more.
Optimizing Web Applications and Web PagesOnce you've maxed out your hardware, tweaked your software, and bought all the bandwidth you can afford, what more can you do? A lot depends on how much influence you have over the design of your Web site. If you control how your Web site is built, you can implement the following recommendations yourself; otherwise, consider them suggestions to bring to your Web site developers and management team.
The first thing to do is analyze your Web site content and make as much of it static HTML as is practical. Although you do want to maintain dynamic interactions with your user, you'll often find that many pages are needlessly built from scripts when storing a few static variations would serve your users' different needs. Static HTML is more quickly and easily served than any other content because it requires no server processing.
Server processing being at a premium, the next thing to do is to reduce the amount of time your server spends processing scripts and data to generate dynamic pages. By this measure, the most voracious consumer of server processing is CGI; CGI scripts take up more processing resources than ASP, and ASP takes up more processing than ISAPI. As much as possible, therefore, convert your CGI scripts to ASP, and anywhere you can convert your ASP to ISAPI, do it.
Here are some further tips:
Microsoft Press SolutionsWhew! You can see that you have a lot of work to do to fully optimize the performance of your IIS 5.0 Web server. Fortunately, you've got a lot of help from Microsoft Press at your disposal. Press books will help you understand the parameters of system performance and how to make your server's performance the best it can be. Check out these titles:
(http://www.microsoft.com/learning/books/Windows/default.mspx). For material that covers .NET Enterprise Servers, see the .NET section
The information in this article is an excerpt from the Windows 2000 Server Resource Kit book, published by Microsoft Press.
Collapse this imageExpand this image
Learn More About Windows 2000 Server Resource Kit
For more information about this publication and other Microsoft Press titles, see http://mspress.microsoft.com
Article ID: 305313 - Last Review: March 29, 2007 - Revision: 4.2
Contact us for more help
Connect with Answer Desk for expert help.