IIS 7.5's Application Warm-Up module eliminates delays By Dino Esposito
Web applications and Web sites built using ASP .NET often face a common problem.
They're often hosted in Microsoft IIS application pools that let resources such as worker processes and settings be shared, to minimize development and maintenance. That's fine-until requests for shared services cause delays as the application pool recycles and .Net and database connections are initialized. IIS 7.5 addresses this problem with the IIS Application Warm-Up module.
IIS App Warm-Up is natively available with IIS 7.5 on Windows Server 2008 R2 and Windows 7; it's available as an extension for IIS 7. Without warm-up enabled, application pool recycling consists of killing the current instance of the worker process and starting a new one. While this is going on, IIS keeps getting requests, causing even more delays. With warm-up enabled, the two operations occur in reverse order-a new worker process starts up, then the old one is killed. When the new process is up and running, it notifies IIS that it's ready to receive requests. At this point, IIS shuts down the old worker process and completes the recycle in a way that doesn't slow down things for the user.
To configure an application pool for warm-up, edit the applicationHost .config file under the IIS directory. The folder is \inetsrv\config under the Windows System32 folder. Change the value of the startMode attribute of the application pool entry from OnDemand to AlwaysRunning. Here's the code snippet:
Because an application pool can host multiple ASP.NET applications, you also need to specify applicability for each particular application. You can do this either by using the IIS Manager interface or entering the following script into the applicationHost.config file:
Alternatively, from within IIS Manager, navigate to the application and select its warm-up applet. Note that it's configured at the host level. Changes are saved to the applicationHost.config file, not the web.config file. This means that the administrator or hosting company decides whether warm-up is allowed and what policies should be applied.
Warm-up is a way to execute some code before the app becomes available, and to preload and possibly cache some data. You can specify the code that makes this happen at the IIS level. The warm-up applet in IIS Manager will give you a dialog box where you enter the URL to the page on your site that will execute the preloading code. You also indicate a range of acceptable HTTP status codes that indicate the success of the operation.
This works with IIS 7 and IIS 7.5. With IIS 7.5, you can also define an auto-start service provider, a managed component that runs any required preloading code for a given application. An auto-start provider is a class that implements the IProcessHost PreloadClient interface. Such providers are registered in the IIS configuration using this code:
There's no visual interface to configure this aspect. You either edit the configuration file manually or resort to the IIS Manager's generic configuration editor.
Dino Esposito is a Windows consultant and author on .NET development. Write to us at firstname.lastname@example.org.
Building A Mobile Business MindsetAmong 688 respondents, 46% have deployed mobile apps, with an additional 24% planning to in the next year. Soon all apps will look like mobile apps – and it's past time for those with no plans to get cracking.
Join us for a roundup of the top stories on InformationWeek.com for the week of December 14, 2014. Be here for the show and for the incredible Friday Afternoon Conversation that runs beside the program.