Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net App Pool Overlapped Recycling Timing?

As best I can tell when a worker process recycles:

a) a new one spins up before the old one shuts down b) the old one shuts down once all the active requests its servicing completes

Is the above accurate?

If so, I have data that I store in SQL once Application_End() fires from the global.ascx file. I pull this data back in when Application_Start() fires.

The problem is based on my testing, the new worker process fires the Application_Start() before my old worker process gets a chance to complete its Application_End().

What are best practices for handling this situation?

cheers in advance

edit: I just noticed a feature on IIS 7 'Disabled Overlapped Recycle' - I'm guessing this is the best route

like image 681
downatone Avatar asked Oct 28 '10 18:10

downatone


People also ask

How long does it take to recycle an app pool?

Show activity on this post. I've noticed that on one of my production web apps, when I manually recycle an app pool, the recycled worker process can take upwards of 60+ seconds to actually be completely destroyed, based on watching it in Task Manager.

How often should an app pool recycle?

By default, an IIS application pool (or “AppPool”) recycles on a regular time interval of 1740 minutes, or 29 hours. One reason for this time interval is that application pools don't recycle at the same moment every day (every day at 07.00 for example).

Why is the IIS default app pool recycle set to 1740 minutes?

The 1740 story Wade suggested 29 hours for the simple reason that it's the smallest prime number over 24. He wanted a staggered and non-repeating pattern that doesn't occur more frequently than once per day.

What happens when app pool is recycled?

What is application pool recycling in IIS? Recycling means that the worker process that handles requests for that application pool is terminated and a new one is started. This is generally done to avoid unstable states that can lead to application crashes, hangs, or memory leaks.


1 Answers

Your description of overlapped recycling is accurate, yes (1); and there is a setting for disabling it, but it's intended to prevent HTTP errors which you would be re-introducing. App pool recycles are a normal occurrence for managed apps (stems from, among other things, a CLR limitation that prevents the unloading of assemblies in the same memory space) that you must design for.

Your technique would be difficult to manage in a web-farm or web-garden scenario.

I think a better design would be to rely on out-of-process storage for the data (using distributed cache products like ScaleOut, App Fabric, and the like) so that all app pools have the same view of the cached data.

(1) - http://mvolo.com/blogs/serverside/archive/2008/02/25/Starting_2C00_-stopping-and-recycling-IIS-7.0-Web-sites-and-application-pools.aspx

like image 139
Nariman Avatar answered Sep 24 '22 01:09

Nariman