Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS app pool recycling randomly every few seconds

I need to determine WHY the application pool is recycling. (its for no obvious reason)

Is there any way to determine this inside of the application_end sub in the global.asax file?

I have put some basic logging in there, so I know WHEN its shutting down, but I cannot tell why.

(and its nothing obvious... it just seems like every couple of requests certain operations cause the application to end. I have turned off every normal reason for recycling such as time outs, memory checks, etc, etc, etc. Same code is working fine on a different server, so I am sure its something wrong with this setup, but what?...)

like image 546
Mitch Van Duyn Avatar asked Oct 12 '22 09:10

Mitch Van Duyn


1 Answers

You don't have to incur overhead to add custom logging, ASP.NET 2.0 health monitoring does the job for you. You can add the following configuration which will log events in the eventlogs with information why Application pool is restarted.

To turn ASP.NET health monitoring ON, you can edit the "master" web.config file, normally found in %systemroot%\microsoft.net\framework\v2.0.50727\config.

  • First, look for <healthMonitoring> in the master web.config

  • Inside the healthMonitoring node, find the <rules> node

  • Inside rules, add the following:

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

Reproduce the issue and look in the Application event log fpr a source of ASP.NET 2.0. This should log why application pool is recycled.

like image 65
amit Avatar answered Jan 01 '23 11:01

amit