tags:

views:

81

answers:

3

I am using ASP.Net4 MVC2 for my application. The first person using the application usually experiences a long wait before the application responds. After that the application is pretty responsive. If the application is idle for 15 minutes, the same person or the next person using the application will experience long wait again. It looks like the application compiles after being idle for 15 minutes. Can someone tell me where I should look to trouble shoot the problem? Thanks.

+3  A: 

It is almost certainly the case that what you are experiencing is app pool recycling. It's true it takes some time to re-initialize after the pool has been recycled, but it shouldn't take all that long. How long is a "long wait"? A second? Several? In IIS you can configure how regularly your app pool recycles. For IIS 7, right-click on your app pool and choose "Advanced Settings" then look at "Idle Time-out". You may consider increasing this value. (Or set to 0 to disable completely.)

Kirk Woll
I set the app pool recycling at 1am each day, but it's still happening during the business hours after some short idle period. The wait is around 30 seconds to 1 minute.
@user266909, but did you adjust the "Idle Time-out"?
Kirk Woll
+1  A: 

You need to accurately diagnose the problem first before you start implementation solutions. First have to verify if it is, in fact, an app pool recycle. You can start by adding this section to your web.config:

<healthMonitoring>
      <rules>
        <add name="Application Lifetime Events Default"
             eventName="Application Lifetime Events"
             provider="EventLogProvider"
             profile="Default"
             minInstances="1"
             maxLimit="Infinite"
             minInterval="00:01:00"
             custom="" />
      </rules>
</healthMonitoring>

It will log and event to the windows event log anytime asp.net recycles itself. It will also gives a reason for the recycle (e.g., someone poked web.config, etc.). If it is a recycle, then you need to figure out why it is recycling. Is it because IIS is set to do it no matter what? Is it because your app is not handling memory correctly and memory pressure is causing asp.net to want to recycle itself? These questions must be answered first.

First determine if it is a recycle by adding to above configuration and why. Once you get the answer you can check memory, etc.

Steve Michelotti
Which section in web.config should I put the <healthMonitoring>? Thanks.
Put it as a direct child of <system.web> - http://msdn.microsoft.com/en-us/library/2fwh2ss9.aspx
Steve Michelotti
A: 

Have a look at the IIS7 application warmup extension.

http://www.iis.net/download/ApplicationWarmUp

Bronumski