Jotsite Water Cooler Area

Post a New Topic

Show Recent Topics 

ASP.NET's threads

Maybe this problem is isolated to my own PC's configuration (Windows XP Pro, IIS 5.0, .NET 1.1) but I'd still like to share the information just in case someone out there can't figure out why they're having performance issues in an ASP.NET application. Seems there is a single thread available to handle page requests for a particular HttpSession, and holding off on a response will lock up the application for that session. How I discovered this issue:

In my tinkering with my Black Sun tool I determined that I should have separate send/receive URLs through which a bunch of XML-formatted commands would flow. I implemented this a while back now, but the browser-bound data was transmitted immediately even if there was no change. Browser-bound data was expensive in terms of bandwidth and server/client CPU cycles, and the faster the browser pinged the server the more bandwidth and cycles were used up.

I recently modified the code to attempt to hold off (not respond immediately) if no change was detected. I discovered that when no timeout was introduced for the hold off, the system would apparently hang where even any changes introduced by that user would not register and allow the update to continue.

ASP.NET does however have a workaround mechanism: generate "ashx" and "ashx.cs" pages which will be called in an "asynchronous" fashion. This means that several callbacks are defined (BeginProcessRequest with an inform-when-complete passed in, and EndProcessRequest) are introduced which need to be handled by custom code that shoves the compute cycles (in my case a thread sleep) into another thread.

My current design uses this workaround and will hold-off a response for up to five seconds, and since the browser-bound page reload is found in the response itself this effectively significantly reduces the amount of data requested/transmitted.

I don't know how far reaching the single-thread-per-session design happens to be, but it's conceivable that this idea was taken from somewhere else -- so be forewarned.

February 04, 2004 (12:11)

Write a Reply