How to warm up the asp.net mvc webapp after an app pool recycle

asp.net-mvciis-8

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?

Best Answer

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

Related Topic