Friday, June 1, 2012

IIS Performance Tuning


1)     Recycling Application Pool

Daily they have to restart IIS to clear the application pool.

An application pool is a set of one or more applications assigned to a set of one or more worker processes.

It is useful to recycle periodically because web apps might have a memory leaks or other conditions that get worse over time.

Schedule a recycle application pool once a day on off-peak hours. 



cid:image002.jpg@01CD3FFB.20EDA9C0

cid:image007.jpg@01CD3FFB.20EDA9C0

2)     Dedicated Application Pool for different applications

cid:image008.jpg@01CD3FFB.20EDA9C0

3)     Web Garden on IIS (Max Worker process) Allocate worker process to different CPU core
By default each Application Pool runs with a Single Worker Process (W3Wp.exe). We can assign multiple Worker Processes With a Single Application Pool. An Application Poll with multiple Worker process is called "Web Gardens". Many worker processes with the same Application Pool can sometimes provide better throughput performance and application response time. And each worker process should have their own Thread and Own Memory space.

Application Pool > Max Worker process

cid:image003.jpg@01CD400F.ADF00D90

 IIS has a Maximum Worker Process setting per App Pool. For my AppPool, I increased this value to 16 on our 8 core (16 w/ hyperthreading) Win2008 Xeon server in hopes of getting more parallel processing of client requests for our IIS hosted WCF Service (net.tcp, .net 4.0). I am not sure that this is having the desired affect as I don't see 16 worker processes in task manager despite a heavy load from my multi-threaded test client.

Web gardens was designed for one single reason – Offering applications that are not CPU-bound but execute long running requests the ability to scale and not use up all threads available in the worker process.
The examples might be things like -
Applications that make long running database requests (e.g. high computational database transaction)
Applications that have threads occupied by long-running synchronous and network intensive transactions

Max Worker Process=10
Max Worker Process=no of CPU


4)     Limit the queue length for application pools

When running an IIS server in worker process isolation mode, limit the queue length for application pools to prevent large numbers of requests from queuing and overloading the IIS web server.
Adding a new request to the queue can result in exceeding the maximum queue length. In turn, the IIS server may reject the requests and send a 503 error to the client. Keep the queue length shorter to boost IIS performance.


5)     IIS HTTP compression

Enable HTTP compression on the Microsoft IIS server to use bandwidth more effectively. This results in faster response times between the IIS web server and compression-enabled browsers.
IIS can provide three compression options, including static files only, dynamic application responses, and both static and dynamic application responses.
Enable dynamic compression for the server when bandwidth is an issue as indicated by IIS server monitoring, but remember that compression consumes CPU time and memory resources significantly.
Sites > Compression>

6)      Use the Expires header in IIS7

Configure the HTTP Expires header to improve IIS server performance. Generally, continuous HTTP requests sent from new website visitors to display pages creates a massive load on the IIS server.
Configuring the Expires header allows caching pages (and page elements such as images, scripts, css, etc.) on the client side and helps avoid unnecessary HTTP requests.

In IIS 7, Expires headers can be enabled in the system.webServer section of the web.config file. Using the Expires header, you can determine how long files can be cached on the client side. This may be a certain number of hours or days in the future or a fixed date.
7)     Windows 2008 Network Settings

8)     Change max concurrent requests per CPU setting

Max Concurent Request is calculated by following formula
(MaxWorkerThreads * no Of CPU) – (MinFreeThreads * no Of CPU)
This is 12 by default on a single-proc machine.
So performance does improve by adding more CORE/CPU(hardware) to your system
So If you have Two Processor with below configuration
maxWorkerThreads               100
minFreeThreads                      88
Than MaxConcurent Request would be
(100*2) - (88*2) =24 Concurent Request
If you add two more Core than
Than MaxConcurent Request would be
(100*4) - (88*4) =48 Concurent Request.


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\2.0.50727\MaxConcurrentRequestsPerCPU

Set this to a value higher than 12 (12 is the default)
[DWORD]
Change the maxConcurrentRequestsPerCPU setting from 12 to 5000. This allowed IIS to process more requests concurrently.


No comments:

Post a Comment

Followers