IIS Web server Tuning best practices
Following are the methods used for tuning IIS Webserver:
- Enabling HTTP Keep-Alives
- Adjusting Connection Timeouts
- Enabling HTTP Compression
- Growing a Web Garden
- Adjusting the IIS Object Cache Time To Live
- Limiting Queue Length
- Adding Memory
- Use of Disk Striping
1). Enabling HTTP Keep-Alives
- Making sure that HTTP Keep-Alives is enabled is one of the several ways to help your IIS server perform optimally.
- If Keep-Alives is enabled, the Web browser can download multiple files without opening and closing the connection every time, as the IIS holds the connection open.
- You can enable HTTP Keep Alives by going to the Internet Information Services, select your server, and right click on the website for which you want the changes to be affected, click on Properties. The radio button which says “Enable HTTP Keep-Alives” must be clicked.
2). Adjusting Connection Timeouts
- The developer would not want to keep the connection open for an indefinite period of time.
- The connection timeout is set to 120 seconds by default in the IIS 6.0. That means a connection would be closed if there is inactivity for 120 seconds of time.
- The server performance is usually increased with shorter timeout periods, but you need to take care if the client’s connection terminates prematurely or not, otherwise there would be a performance degrades seen.
- You can adjust the Connection timeout by going to the Internet Information Services, select your server, and right click on the website for which you want the changes to be affected, click on Properties. In the Connection timeout field, enter the number of seconds.
You can monitor the connection timeout by enabling logs in the web server and selecting counters like MemoryPages/sec, % Processor time, Current Connections, Total Connection attempts. The current connections must reduce without any drastic increase in the Total Connection attempts. This has to be monitored for some days along with application testing to conclude if we are doing it right.
3). Enabling HTTP Compression
- There are 2 types of compression
– Compression of static pages
– Compression of dynamic pages
- Compression can be enabled by right-clicking on the IIS’s Web Sites container, select Properties. Select the Service tab in the resulting window. There are 2 check boxes – One to compress static files, another to compress dynamic files.
- Static compression takes care of these extensions by default – html, htm,txt
- Dynamic compression takes care of these extensions by default – .dll, .exe, .asp
- There is an option where you can specify the location where the temporary compressed files are stored and also its size.
Advantages and disadvantages of compression
Although compression conserves bandwidth, it can still be at a disadvantage at times as it takes lot of disk space and CPU time
Enabling static compression is a good idea when your website contains mostly static files as these can be compressed and cached easily. The files would be re-compressed only when the original file changes, not otherwise.
It is also beneficial when you have a lot of disk space to spare.
Enabling dynamic compression would not be that great if there is a lot of dynamic content in your application. This is because dynamic content would not be cached and it will need higher processor usage to re-compress every time a client passes a request.
HTTP Compression is not ideal when your % Processor Time counter is above 80%, also when you have inadequate disk space.
You can monitor the HTTP Compression by enabling logs in the web server and selecting counters like MemoryPages/sec, % Processor time, Current Connections, Total Connection attempts. The Pages/sec loaded must increase without any drastic change in the other parameters. This has to be monitored for some days along with application testing to conclude if we are doing it right.
4). Growing a Web Garden
- Web garden is a way of assigning multiple worker processes.
- The benefits of several worker processes are many. When an application causes a worker process to hang, like for example Infinite loops, then the other worker processes can come into play and keep servicing requests.
- You can achieve this by right clicking on the application pool, selecting Properties and assigning the number of worker processes.
5). Adjusting the IIS Object Cache Time to Live
- Any object that is requested by the client would be cached by IIS.
- The Time To Live value is set to 30 seconds by default.
- Reducing the TTL is a nice way to gain some memory back for other functionalities if the server is a little short on memory.
- If the server has a lot of free memory and mainly static pages, then it’s a good idea to improve performance by increasing the Time To Live or TTL.
- The TTL can be set from the Registry editor from 0 (caching not present) to 4,294,967,295 i.e. the max time limit that says unlimited caching.
6). Limiting Queue Length
When there is heavy traffic in the site, it would sometimes be better that you indicate some visitors to exit from the site than wait endlessly.
- Limiting the queue length also takes care that any person, whose request is being queued, would definitely be served within a good amount of time.
- All the other people would receive a notice saying that the server is busy and they can leave the site.
7). Adding Memory
It is good to add more RAM to your machine. If the RAM is more in your machine, less paging occurs which is a good thing as paging results in the machine running much slower and is extremely inefficient at times.
8). Use of Disk Striping
Disk striping is quite effective. This spans files across multiple/several hard drives so that we can achieve the benefits of combined performances of multiple/several drives.