I've been investigating why some of our ASP.NET webpages sporadically take 10-20 seconds to load, when on average they take 500-700 ms.
The NewRelic instrumentation shows that the delay always happens due to uninstrumented code in BeginRequest.
|13 fast method calls||0.000 s|
|Uninstrumented time||0.000 s|
|4 fast method calls|
After some digging around, I found a few articles that hint this could be due to deadlock issues with Microsoft session module implementation. When you have a page, containing several iframes, these iframes can be concurrently requesting the same session ID from a session state resulting in a deadlock and a delay.
There's a good StackOverflow discussion right here which Demis Bellot pointed me to:
What they recommend to do is to reimplement the session module using MSDN's
custom session handler class (http://msdn.microsoft.com/en-
us/library/system.web.). The only problem is that that class is not thread safe. sessionstate. sessionstateutility.aspx
So I started tweaking the class and came up with the following source code, which you can download from: http://www.cs.yale.edu/~yampolsk/SessionDemo.rar
. I am planning to put it into Production next week and measure the results.
Simple Apache benchmarking of default MS session handler and this one, result in almost identical performance.