What can you do to speed up IIS web sites? Here are 10 solid performance optimization tips for Internet Information Service. IIS Version 5.1 to IIS Version 10
Last updated on March 15th, 2018 at 02:34 pm
- 1 Helpful IIS eBooks You May Like
- 2 Optimizing IIS Performance
- 3 Verify Sites Connection Limit are at maximum
- 4 Consider Installing WinCache Extension for PHP
- 5 Enable Static & Dynamic Content Compression in IIS
- 6 Configure HTTP expires header
- 7 Disable ASP.Net debugging from Web.Config
- 8 Catch and View All Errors, Use ELMAH (Error Logging Modules and Handlers)
- 9 Use Google Analytics & Reconsider relying on IIS Logging
- 10 Configure the Idle Timeout Feature for all Application Pools
- 11 Common Server Tuning Methods for Tuning the IIS Hardware
- 12 Tune the Performance of ASP, ASP.NET, and ISAPI Applications
- 13 Helpful IIS eBooks You May Like
Helpful IIS eBooks You May Like
Optimizing IIS Performance
Websites 10 years ago seems like a kindergarten project compared to websites of today now are in 2018 and If you host one or more Web sites that receive some amount of traffic,Internet Information Services (IIS) performance is extremely important to you. To enhance performance, you could always use cloud services, cluster your IIS servers or buy more bandwidth, but this tends to be a little expensive and doesn’t always solve the scalability problems.
Fortunately, there are other things that you can do to boost IIS performance for free. In this article, I will share 10 solid performance techniques that by themselves may not dramatically improve performance, but combined can result in significant performance gains.
We know best as we have over a dozen fully loaded IIS servers in house hosting systems ranging from WordPress (PHP) to feature rich ASP.Net SAAS applications.
Applicable IIS Versions:
- IIS Version 5.1 for Windows XP Pro
- IIS Version 6.0 for Windows Server 2003
- IIS Version 7.0 for Windows Vista and Windows Server 2008
- IIS Version 7.5 for Windows 7 and Windows Server 2008 R2
- IIS Version 8.0 for Windows 8 and Windows Server 2012
- IIS Version 8.5 for Windows 8.1 and Windows Server 2012 R2
- IIS Version 10 For Windows 2016 and Windows 10
Verify Sites Connection Limit are at maximum
The <limits> element of the <site> element configures settings that limit the amount of bandwidth, the number of connections, or the connection time-out for client requests to a site. Make sure that IIS doesn’t have max bandwidth set to something low.
How to configure the connection limit options for a site
- Open Internet Information Services (IIS) Manager:
- In the Connections pane, expand the server name, expand the Sites node, and then click the name of the site.
- In the site’s Home pane, click Advanced Settings… in the Actions pane.
- In the Advanced Settings dialog box, expand Limits, specify connection limit options, and then click OK.
Sites Connection Limit Configuration
connectionTimeout Optional timeSpan attribute. Specifies the time (in seconds) that IIS waits before it disconnects a connection that is considered inactive. Connections can be considered inactive for the following reasons:
- The HTTP.sys Timer_ConnectionIdle timer expired. The connection expired and remains idle.
- The HTTP.sys Timer_EntityBody timer expired. The connection expired before the request entity body arrived. When it is clear that a request has an entity body, the HTTP API turns on the Timer_EntityBody timer. Initially, the limit of this timer is set to the connectionTimeout value. Each time another data indication is received on this request, the HTTP API resets the timer to give the connection more minutes as specified in the connectionTimeout attribute.
- The HTTP.sys Timer_AppPool timer expired. The connection expired because a request waited too long in an application pool queue for a server application to dequeue and process it. This time-out duration is connectionTimeout.
The default value is 00:02:00 (two minutes).
maxBandwidth: Specifies the maximum network bandwidth, in bytes per second, that is used for a site. Use this setting to help prevent overloading the network with IIS activity. The default value is 4294967295.
maxConnections: Specifies the maximum number of connections for a site. Use this setting to limit the number of simultaneous client connections. The default value is 4294967295.
maxurlSegments Optional uint attribute. Specifies the maximum number of segments permitted in a URL. The default value is 32.
Windows Cache Extension for PHP is a PHP accelerator that is used to increase the speed of PHP applications running on Windows and Windows Server. Once the Windows Cache Extension for PHP is enabled and loaded by the PHP engine, PHP applications can take advantage of the functionality without any code modifications.
Increase PHP application performance on Windows by caching PHP bytecode in memory
Windows Cache Extension for PHP stores the PHP bytecode, the compiled version of the PHP script, in memory making it available when subsequent executions of the same script are needed helping to increase the overall PHP application performance. The use of Windows Cache Extension for PHP allows the PHP bytecode to be generated only once and to be reused each time the same PHP script is executed.
Reduce file system I/O overhead by caching the PHP scripts in memory
Windows Cache Extension for PHP helps to reduce the latency of file operations when PHP scripts are stored on remote UNC file shares. Windows Cache Extension for PHP includes a file system cache that is used to store the content of the PHP script files in shared memory, which reduces the amount of file system operations performed by PHP engine.
Leverage the User Cache API’s to further improve the execution speed of PHP scripts
Windows Cache Extension provides user cache API’s, that can be used by PHP scripts to store PHP objects and variables in shared memory. This way PHP scripts may improve the execution speed by storing processed data in the cache and then using it in subsequent requests instead of re-creating the data on every request.
Avoid redundant mapping for absolute paths by using relative file path cache
Windows Cache Extension for PHP caches the relation between relative and absolute file paths, reducing the number of relative path resolutions performed by the PHP engine. PHP applications that use many relative paths would perform faster given the conversion to absolute paths is performed only once.
Enable Static & Dynamic Content Compression in IIS
If your sites use lots of bandwidth, or if you want to use bandwidth more effectively, enable compression to provide faster transmission times between IIS and compression-enabled browsers. If your network bandwidth is restricted, as it is, for example, with mobile phones, compression can improve performance.
Compression in IIS 7.x is configured with two .config file elements in the space. The elements can be set anywhere in the IIS/ASP.NET configuration pipeline all the way from ApplicationHost.config down to the local web.config file. The following is from the the default setting in ApplicationHost.config (in the %windir%\System32\inetsrv\config forlder) on IIS 7.5 with a couple of small adjustments (added json output and enabled dynamic compression)
IIS provides the following compression options:
- Static files only
- Dynamic application responses only
- Both static files and dynamic application responses
Compression of dynamic application responses can affect CPU resources because IIS does not cache compressed versions of dynamic output. If compression is enabled for dynamic responses and IIS receives a request for a file that contains dynamic content, the response that IIS sends is compressed every time it is requested. Because dynamic compression consumes significant CPU time and memory resources, use it only on servers that have slow network connections but that have CPU time to spare.
Unlike dynamic responses, compressed static responses can be cached without degrading CPU resources.
This task includes the following procedures:
Configure HTTP expires header
This feature helps to minimize the number of http requests send to IIS by website visitors. HTTP expires header will help the client browser to cache webpages and its elements such as images, CSS etc. To set http expires you need to click on HTTP response headers in the IIS, and then click on “set common headers”. Next select ‘expire web contents” and select the number of days or hours—this is total time your contents will be cached in the client’s browser.
Disable ASP.Net debugging from Web.Config
Ensure that the debug=”false” on the compilation element in the web.config file of each and every ASP.NET application on the server. The default during development is “true” and it is a common mistake to allow this development time setting to find its way onto production servers during deployment. You don’t need it set to true in production and it often leads to memory overhead and inefficiencies.
For more information about what the consequence for setting debug=”true”, check ASP.NET Memory: If your application is in production… then why is debug=true
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 debugging, click on your server name in IIS and then right click on it to enable feature view. One the right pane, click on ‘compilation’ and then click on ‘debugging properties’. Next, set the following values as given below:
Server side debugging: false
Client side debugging: false
- Click Start, point to All Programs, click Administrative Tools, and then click Internet Information Services (IIS) Manager.
- 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.
- 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.
- If necessary, click Apply in the Actions pane.
Catch and View All Errors, Use ELMAH (Error Logging Modules and Handlers)
This point hits home to me personally because this little tool has saved my jobs countless of times. In short, ELMAH works at the site level to catch every errors within your Application and alert you right away, get immediate errors via SMTP, store them in SQL Server, SML, MSACCESS etc.
ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.
Once ELMAH has been dropped into a running web application and configured appropriately, you get the following facilities without changing a single line of your code:
- Logging of nearly all unhandled exceptions.
- A web page to remotely view the entire log of recorded exceptions
- A web page to remotely view the full details of any one logged exception, including colored stack traces.
- In many cases, you can review the original yellow screen of death that ASP.NET generated for a given exception, even with customErrors mode turned on.
- An e-mail notification of each error at the time it occurs.
- An RSS feed of the last 15 errors from the log.
Implementation is as simple as copying the ELMAH dll to your Bin Directory, configure Web.Config to store or send out ELMAH logs and via real time error logs in table format and yellow screen via http://yoursite:PORT/elmah.axd
Use Google Analytics & Reconsider relying on IIS Logging
IIS by default logs lot of data like client IP address, User Name, Method, URI stem, Protocol status, User agent and lot of other attributes. All of those attributes are not required by your application. You can easily customize what data to log and what to avoid. This results in reduced bandwidth.
Follow below steps to customize IIS logging.
- Open IIS manager (inetmgr).
- Click on <server name> -> Sites -> <your site>
- Double click on Logging module from middle pane of window.
- From new window click on Select Fields
- You will see a new window where you can select or de select logging attributes. Click Ok and from parent window right pane click Apply.
Configure the Idle Timeout Feature for all Application Pools
Through the idle timeout feature, users can enhance web server performance by enabling IIS to shut down idle worker processes. Enabling the idle timeout feature assists in eliminating system resource wasting that normally occurs when worker processes run idly. It allows users to better manage system resources, preserve resources so that they are available when needed, and free up resources.
To enable the idle time feature:
- Open IIS Manager.
- Right-click the Application Pool node in the console tree and select Properties from the shortcut menu.
- Click the Performance tab.
- In the Performance tab’s Idle Timeout area, enable the available checkbox and specify the inactivity time duration after which the worker process should shut down. The default setting is 20 minutes.
- Click OK.
Common Server Tuning Methods for Tuning the IIS Hardware
A few common methods that should be considered to tune the performance of the IIS machine:
- Consider using an SMP-capable motherboard in order to easily add a CPU to improve processing power.
- If using Windows Server 2003, use its capability of effectively defragmenting NTFS drives to ensure that the disk subsystem performs efficiently.
- Consider setting a large enough fixed paging file size and distributing the paging file over multiple drives. This also assists in improving the disk subsystem performance.
- Consider using a hardware RAID solution over software RAID. Software RAID solutions place an additional burden on the processor subsystem.
- If the Web servers host e-commerce sites, consider using Windows clustering and network load balancing (NLB).
- The simplest way to improve the IIS machine’s performance is to add additional RAM.
- Maximize data throughput so that the RAM is utilized efficiently. Enable Maximize Data Throughput via the Control Panel. A few benefits of enabling Maximize Data Throughput is SMP scalability on multiprocessor machines, improved networking performance, and support for a larger amount of physical memory
To enable Maximize Data Throughput:
- Open Control Panel.
- Click Network Connections then select Local Area Connection.
- Click the General tab then click Properties.
- When the Local Area Connection Properties dialog box opens, select File and Print Sharing for Microsoft Networks, then click Properties.
- Select the Maximize Data Throughput for Network Applications option.
- Click OK.
- IIS logging depletes processor, disk, and memory resources. Therefore, do not extensively enable IIS logging. Before enabling remote logging, be sure to check for any performance impacts. Remote logging is definitely slower.
- It is recommended to not enable ODBC logging because it disables IIS kernel-mode caching.
- When using virtual directories, use the local IIS machine over mapping them to a share located on a remote server.
- Use the FTP user isolation feature with caution. It is recommended to use a separate IIS machine for FTP if FTP user isolation must be used.
- Steer clear of old CGI applications. A better solution would be to use ASP or ASP.NET applications.
- Also, use ISAPI extensions over ISAPI filters. It is recommended to rewrite any existing ISAP filters to operate as ISAPI extensions.
- Save CPU resources by disabling content indexing if user search pages are not being applied.
Tune the Performance of ASP, ASP.NET, and ISAPI Applications
A few common tuning methods that can be used for applications running on IIS 6 are:
- Static HTML files because they utilize less memory and processor resources
- Because SSL encryption needs extensive CPU resources, only use it when really necessary.
- Configure expire headers for static HTML files and for image files.
Helpful IIS eBooks You May Like
Tune ASP.NET applications for high performance by implementing the following best practices:
- Caching should be enabled
- All input validation should be performed on the client
- If it is not being utilized, disable Session State
- It is recommended to store application session data out-of-process if web gardens and web farms are being deployed.
- Utilize stored procedures to access data on SQL servers. Do not use ad hoc queries.
- For VBScript code, utilize Option Strict.
- Trap exceptions rather than use it for directing program flow.
How to enable ISAPI caching to improve application performance on IIS 6:
- Open IIS Manager.
- Open the Properties window for the website that contains the particular application.
- Click the Home Directory tab.
- Click Create to enter a name for the application if it needs one.
- Click the Configuration button
- When the Application Configuration Properties dialog box of the application opens, click the Mappings tab.
- Select the Cache ISAPI Extensions checkbox.
- Click OK.