views:

56

answers:

1

I am running an ASP.NET application on an IIS7 server. It has been running fine for a long time, but over the past week or so it has been discarding all users' sessions several times a day. I enabled all of the application pool recycle logging options as described in http://blogs.iis.net/ganekar/archive/2008/12/12/iis-7-0-application-pool-recycles-log-a-event-in-windows-event-log.aspx, but I didn't get anything in my event log.

There are no errors in the event log, and no visible symptoms except that all my users lose their sessions.

Are there any other reasons that IIS would recycle my application pool? Is there any other type of logging that I can enable to find out what is happening?

+1  A: 

When you experience this behavior, how recently have you done a deployment of your files to the server?

There is a nasty configuration option called numRecompilesBeforeAppRestart on the compilation tag:

<system.web>
    <compilation debug="true" numRecompilesBeforeAppRestart="15">

http://msdn.microsoft.com/en-us/library/system.web.configuration.compilationsection.numrecompilesbeforeapprestart.aspx

This value defaults to 15. I've been through an application killing all user sessions before and this was the culprit for me. For roughly a day after a lightly used web application was updated (new files copied to the server; this ended up overwriting EVERY file, numbering into the hundreds), we'd get constant AppDomain restarts evidenced by all Session values for all users disappearing.

I found this bug report listing the behavior I'm experiencing: http://support.microsoft.com/kb/319947

Here is the really important relevant text to my scenario:

However, this problem occurs when you load many new .aspx or .ascx files to the server (for example, 61 files). The server unloads the application when the first 15 files are recompiled and every time another 15 files are recompiled until the server reaches 61. This results in four application restarts even though only one is required.

I switched the value to 99999 and the problem went away. This means more memory will build up in my worker process, so I added a daily recycle (3am when my site has no users) to the IIS AppPool recycle settings.

Adam Sills
+1 nice link...
slugster
Hopefully now that it's on SO, it'll be easier to find via Google.
Adam Sills
That was an interesting article, but my problem is different. That bug seems to involve multiple application restarts in a short period of time after a large update. Our last update was about a week ago, and the restarts seem to happen over longer time spans.
Josh Yeager
"Short" is relative... when it happened to me, it would easily last an entire day, occasionally it would *seem* to last longer. We'd update a couple hundred pages, which wouldn't all get used for quite a while. As the users explored larger parts of the application, application restarts would occur. We'd get one in the morning, then hours later get another, then at night get another. Depending on the size of the update and # of pages and controls, the problem can persist for quite a while.
Adam Sills
So, in your case, the restarts would be triggered whenever a user hit a page that had not been hit since the update?
Josh Yeager
Correct, and it seemed random. Say we'd update 90 ASPX and ASCX pages... as the users slowly explored the site as the day went on (it is a lightly used site), on ASPX/ASCX file #15 the site would restart. And so on. Sometimes they would happen over two days (no customers using the site those days - this happens occasionally), and other times they'd all happen in 2-3 hours and it would work for another week without problem.If I were you, I'd bump that value in your config just to rule it out (include an AppPool restart with your update).
Adam Sills