How can I warm up my asp.net mvc webapp after an app pool recycle?

Solution 1:

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

<applicationInitialization
     doAppInitAfterRestart="true" >
   <add initializationPage="/" />
</applicationInitialization>

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 then Advanced Settings

enter image description here

and Preload for your site itself (right click on the site then Manage Site then Advanced Settings

enter image description here

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)

enter image description here

3. Disable periodic recycling

also turn off Regular Time Interval (minutes) by default IIS would recycle your app every 29 hours.

enter image description here

For

Solution 2:

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.