Peter Nguyen Team : Web Development Tags : Web Development

Preloading your application pools

Peter Nguyen Team : Web Development Tags : Web Development

There has always been one thing that frustrated me the most about compiled code – the time it takes for your web application to start up for the first time in IIS. The .net compiler kicks in, the application pool spins up and your code is being generated behind the scenes. This can take minutes, and people generally don’t want to wait minutes for their website to start up.

Coming from an open source/non-compiled PHP/Linux development environment, this has always been one of my major concerns. In fact, even Microsoft’s own Sharepoint takes up to 5 minutes to spin up after an IIS reset.

Something that I’ve recently discovered, and is in fact built in to the upcoming IIS 8.0, is the ability to keep your application pools running in standby and warm. For sites with low traffic, and the application pools automatically recycling after 20 minutes of inactivity, this could speed up the overall performance of the site dramatically. No more “it’ll be fast once it gets going” excuses.

What you do is you is:

1.      Install the Application Initialization module for IIS7.5 (available in the Web Platform Installer - http://www.iis.net/download/ApplicationInitialization)

2.      Modify the server’s applicationHost.config by looking for your application pool and adding startMode=”AlwaysRunning”, for example:

startMode="AlwaysRunning" managedRuntimeVersion="v4.0" />

3.      Look for your site in the element and add preloadEnabled=”true”, for example:

preloadEnabled="true" applicationPool=".NET v4.5">

4.      Restart IIS, wait a few minutes, and voila! Your application is instantly faster due to the pre-loading of your application pool and website.

For further documentation – you can visit: http://learn.iis.net/page.aspx/1089/iis-80-application-initialization/#TOC301259898