Tuesday, 15 December 2015

IIS Configuration For Best Performance

Common Problem areas in IIS Performance are 

  1. Memory leak
  2. Thread Limit
  3. High cpu usage
  4. Cache
  5. HTTP compression
  6. Connection limtation
Configuration to improve IIS performance

Internet Information Services (IIS) exposes numerous configuration parameters that affect IIS performance. The following points describes several of these parameters and provides general guidance for setting the parameter values to improve IIS performance.

  • Configure Logging option(Log only essential information or completely disable IIS logging)
  • Disable IIS ASP debugging in production environments
  • Tune the value of the ASP Threads Per Processor Limit property
  • Tune the value of the ASP Queue Length property
  • Tune the MaxPoolThreads registry entry
  • Configure ASP.NET 2.0 MaxConcurrentRequests for IIS 7.5/7.0 Integrated mode
  • Enabling CPU Monitoring in IIS
  • Improving IIS Scalability and Availability with Network Load Balancing
  • Enable IIS HTTP compression
  • Configure HTTP expires header
  • Enable Output caching
  • Connection Limit in IIS
upload_2015-12-15_10-18-56.png

Configure Logging option(Log only essential information or completely disable IIS logging

With default settings, IIS logs almost everything under the hood . which results memory consumption and increase the response time . so to consume less memory You either can disable logging option or can select a number of essential events to log in your server. To disable logging follow these steps:

1. Click Start, point to All Programs, click Administrative Tools, and then click Internet Information Services (IIS) Manager.

2. In the Connections pane, click to expand Sites, click to select the Web site for which you would like to disable logging, click to select Features View, and then double-click the Logging feature.

3. Click Disable in the Actions pane to disable logging for this Web site.

Remember that you can set logging option both in server level and website level.

Disable IIS ASP debugging in production environments

When you run your server in the production environment, you may not need to run “ASP debugging” mode. Stopping debugging mode will save you a great amount of processing power. To disable IIS ASP debugging follow these steps:

1. Click Start, point to All Programs, click Administrative Tools, and then click Internet Information Services (IIS) Manager.

2. In the Connections pane, click to expand Sites, click to select the web site for which you would like to disable ASP debugging, click to select Features View, and then double-click the ASP feature.

3. Click to expand Compilation, click to expand Debugging Properties, and verify that both Enable Client-side Debugging and Enable Server-side Debugging are set to False.

4. If necessary, click Apply in the Actions pane.

Disable debugging for ASP.NET Applications and Web Services by specifying the <compilation debug="false"/> section in the web.config file for the web application.
upload_2015-12-15_10-20-12.png

Tune the value of the ASP Threads Per Processor Limit property

The ASP “Threads Per Processor Limit property” specifies the maximum number of worker threads per processor that IIS creates. Increase the value for the Threads Per Processor Limit until the processor utilization meets at least 50 percent or above. This setting can dramatically influence the scalability of your Web applications and the performance of your server in general. Because this property defines the maximum number of ASP requests that can execute simultaneously, this setting should remain at the default value unless your ASP applications are making extended calls to external components. In this case, you may increase the value of Threads Per Processor Limit. Doing so allows the server to create more threads to handle more concurrent requests. The default value of Threads Per Processor Limit is 25. The maximum recommended value for this property is 100.

To increase the value for the Threads Per Processor Limit follow these steps:

1. Click Start, point to All Programs, click Administrative Tools, and then click Internet Information Services (IIS) Manager.

2. In the Connections pane, select the web server, click to select Features View, and then double-click the ASP feature.

3. Click to expand Limits Properties under Behavior, click Threads Per Processor Limit, enter the desired value for Threads Per Processor Limit and click Apply in the Actions pane.

Tune the value of the ASP Queue Length property

The goal of tuning this property is to ensure good response time while minimizing how often the server sends the HTTP 503 (Server Too Busy) error to clients when the ASP request queue is full. If the value of ASP Queue Length property is too low, the server will send the HTTP 503 error with greater frequency. If the value of “ASP Queue Length property” is too high, users might perceive that the server is not responding when in fact their request is waiting in the queue. By watching the queue during periods of high traffic, you should discern a pattern of web request peaks and valleys. Make note of the peak value, and set the value of the ASP Queue Length property just above the peak value. Use the queue to handle short-term spikes, ensure response time, and throttle the system to avoid overload when sustained, unexpected spikes occur. If you do not have data for adjusting the ASP Queue Length property, a good starting point will be to set a one-to-one ratio of queues to total threads. For example, if the ASP Threads Per Processor Limit property is set to 25 and you have four processors (4 * 25 = 100 threads), set the ASP Queue Length property to 100 and tune from there.

To increase the value for the Queue Length property follow these steps:

1. Click Start, point to All Programs, click Administrative Tools, and then click Internet Information Services (IIS) Manager.

2. In the Connections pane, select the Web server, click to select Features View, and then double-click the ASP feature.

3. Click to expand Limits Properties under Behavior, click Queue Length, enter the desired value for Queue Length and then click Apply in the Actions pane.

Note - Because this property can only be applied at the server level, modification of this property affects all Web sites that run on the server.

Tune the MaxPoolThreads registry entry

This setting specifies the number of pool threads to create per processor. Pool threads watch the network for requests and process incoming requests. The MaxPoolThreads count does not include threads that are consumed by ISAPI applications. Generally, you should not create more than 20 threads per processor. MaxPoolThreads is a REG_DWORD registry entry located at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\InetInfo\Parameters\ with a default value of 4.

Configure ASP.NET 2.0 MaxConcurrentRequests for IIS 7.5/7.0 Integrated mode

ASP.NET 2.0 restricts the number of concurrently executing requests instead of the number of threads concurrently executing requests. For synchronous scenarios, this will indirectly limit the number of threads because the number of requests will be the same as the number of threads. But for asynchronous scenarios, the number of requests and threads will likely be very different because you could have far more requests than threads. When you run ASP.NET 2.0 on IIS 7.5 in integrated mode, the minFreeThreads and minLocalRequestFreeThreads of the “httpRuntime” element in the machine.config are ignored. For IIS 7.5 Integrated mode, a DWORD named MaxConcurrentRequestsPerCPU within HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727.0 determines the number of concurrent requests per CPU. By default, the registry key does not exist and the number of requests per CPU is limited to 12. .NET Framework 3.5 SP1 includes an update to the v2.0 binaries that supports configuring IIS application pools via the aspnet.config file. This configuration applies to integrated mode only (Classic/ISAPI mode ignores these settings).The new aspnet.config config section with default values is listed below:

In IIS 7.5 Integrated Mode, the maxWorkerThreads and the maxIoThreads parameters in the “processModel” section of the machine.config file are not used to govern the number of running requests, but they are still used to govern the size of the CLR thread pool used by ASP.NET. When the “processModel” section of the machine.config has “autoConfig=true” (which is the default setting), this will give the application pool up to 100 worker threads (MaxWorkerThreads) per logical CPU. So a common commodity server with 2 dual-core CPUs would have 400 MaxWorkerThreads. This should be sufficient for all but the most demanding applications.

Specifies configuration settings that are used by ASP.NET to manage process-wide behavior when an ASP.NET application is running in Integrated mode on IIS 7.0 or a later version.

This element and the feature it supports only work if your ASP.NET application is hosted on IIS 7.0 or later versions.

No comments:

Post a Comment