IIS Worker process hangs forever on first request

AndersDaniel picture AndersDaniel · May 24, 2012 · Viewed 7k times · Source

I am working on solving a problem that I have had for a couple of days now. Every time one of my sites are rebuild or the AppPool is recycled, the first pageload will hang forever (well, I've only waited up to 30 minutes). It is only happening on one particular site out of ~10 sites. It is an ASP.NET site.

Here are the things I have observed:

  • In IIS Manager under worker processes I can see the request. Verb = GET, Sate = ExecuteRequestHandler, Module Name = ManagedPipelineHandler. Time Elapsed just keeps increasing, of course.
  • If I close down the browser in which I made the initial request and then open a new one to make another request, the page will load instantly.
  • In my code the Application_Start of my Global.asax file is not called on the first request. It is called on the second request.
  • The worker proccess is causing the memory usage on my machine to go through the roof

I'm inexperienced in troubleshooting IIS, but hours and hours of searching has led me nowhere.

The only major code change we have made on the site recently is that we have started implementing logging using log4net. I have though tried to remove any log4net code, both from my web.config file and Global.asax - still no luck.

Has anyone else experienced this and if so how did you solve it?

Any and all help will be much appreciated.

ADD: If I place a .txt file in the root of the site and load that as the first thing after a build it will load instantly. However the worker proccess still acts exactly as before and the memory usage still goes through the roof.

Final edit:

I feel like such an idiot. I can't explain why, but for some reason my break points in Global.asax suddenly got hit and I was able to identify the problem. It was a call to a database via Entity Framework that was badly written - i.e. the filtering was done after all the rows from the column in question had been fetched. And to make it worse, the filtering was done inside a foreach loop. Anyway, now everything is back to normal and I'm happy.

Answer

Bex picture Bex · May 24, 2012

Possibly stating the obvious but you haven't got any silly code in your global asax in the app_start that could be causing this?

Sounds like an infinite loop or something?