I am running an ASP.NET MVC webapp in IIS 8.0. My application needs to be warmed up before taking requests. We already have a process to warm up the application automatically when we deploy new code. However, we are seeing periodic App Pool Recycle events that are resulting in the app not being warmed up.
Is there a best practice for detecting an app pool recycle event and executing a script or some code?
There are several things you can do:
1. Application Initialization
You can use Application Initialization Module which comes in-box with IIS 8.0
you can have something like this in your
web.config
This will send a request to the root of your app (
initializationPage="/"
) every time your app starts automatically.You can also configure the Start Mode for your application pool to
Always Running
which means every time IIS restarts, it will make sure to start your application pool immediately (this if from right click on your application pool thenAdvanced Settings
and
Preload
for your site itself (right click on the site thenManage Site
thenAdvanced Settings
2. Disable Idle Time-out
Additionally you can disable idleTimeout (by default IIS will shut down the app after 20 minutes of in activity) by changing the of in
Idle Time-out
for your application pool to 0 (infinite)3. Disable periodic recycling
also turn off
Regular Time Interval (minutes)
by default IIS would recycle your app every 29 hours.For
From my experience, AlwaysRunning and Preload enabled doesn't get much speed up. The most wait time goes on dynamic compilation (which can be fixed with aspx precompile) and loading assemblies into memory and caching.