tsJensen

A quest for software excellence...

ASP.NET, Threading and Application Pools

Thread Abortion
Why is my app working in my Windows XP Pro machine and not on the Windows Server 2003 production machine? I have two ASP.NET apps that run on the same server and interact between one another. Why? Because eventually they will go their separate ways behind a load balancer onto many machines. And I was logging unexplained ThreadAbort exceptions.

Clue: IIS 6 and Application Pools
After working on fine tuning my code nearly all day and still getting the same result, it dawned on me that the two unique Application Pools that I had created on which the two ASP.NET apps would run had properties. Doh! Check out the properties.

Application Pool Properties
I made the following changes on the assumption that because each request to the application would launch work on a ManagedThreadPool and return something immediately. Because of that, the settings of the application pool would allow the process to be killed and/or cycled while executing on those working threads and generate the unexpected ThreadAbort exception.

  • Recycling tab - disable the check boxes
  • Performance tab - diable the check boxes
  • Health tab - uncheck "Enable rapid-fail protection"

Positive Result
Ran the test again and alakazam! No ThreadAbort exceptions.

Threading on ASP.NET
There have been several issues I've run into over the past few months in dealing with handling work after the request has long since been sent back to the client. Using the ThreadPool vs the ManagedThreadPool from Stephen Toub and this Application Pool thing have been among the trickiest.

What are the dangers?
I'm sure there are dangers in disabling the safety net around the Application Pool. So I'm making sure that these two apps run on their own. I may experiment with re-enabling them one at a time and observing the result. If you have any advice for me on the matter, I'd love to hear from you.