Pages

What Programming Language Should I Use to Build a Startup?

Often entrepreneurs ask me 'What technology should I build my startup on?' There is no right or wrong answer to this question. It's a decision every company makes for itself, depending on what it's trying to build and the skills of its cofounders. Nonetheless, there are a few rules that one should adhere to. We discuss them in this blog post.

Incident Response Policy

What happens in your company when a production incident occurs? Usually in a typical startup, you will see engineers running around frantically trying to resolve the problem. However, as soon as the incident is resolved, they forget about it and go back to their usual business. A good incident response policy can help bring order into chaos. We provide a sample template in this blog post.

Why Software Deadlines Never Make Sense

We discuss why software deadlines usually don't make sense.

Analyzing Front-End Performance With Just a Browser

We discuss a number of freely available online tools which can be used to analyze bottlenecks in your website.

Why Smaller Businesses Can't Ignore Security and How They Can Achieve It On a Budget

In this article, we show that security is both important and achievable for smaller companies without breaking a bank.

Friday, November 25, 2011

Sporadic delays in BeginRequest of ASP.NET webpages

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,812
100.00%
System.Web.HttpApplication.BeginRequest()0.000 s
0.0
0.00%
13 fast method calls0.000 s
0.0
0.00%
Aptimize.WebAccelerator.OptimizerModule.OptimizerModule_BeginRequest()0.000 s
0.0
0.00%
ASP.global_asax.Application_BeginRequest()0.000 s
0.0
0.00%
System.Web.Security.FormsAuthenticationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Handlers.ScriptModule.AuthenticateRequestHandler()0.000 s
0.0
0.00%
System.Web.Security.DefaultAuthenticationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Security.RoleManagerModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Security.AnonymousIdentificationModule.OnEnter()0.000 s
0.0
0.00%
System.ServiceModel.Activation.HttpModule.ProcessRequest()0.000 s
0.0
0.00%
System.Web.Security.UrlAuthorizationModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Caching.OutputCacheModule.OnEnter()0.000 s
0.0
0.00%
System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache()0.000 s
0.0
0.00%
System.Web.HttpApplication+MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()0.000 s
0.0
0.00%
System.Web.Routing.UrlRoutingModule.OnApplicationPostMapRequestHandler()0.000 s
13,578
98.31%
Uninstrumented time 0.000 s
0.0
0.00%
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.sessionstate.sessionstateutility.aspx). The only problem is that that class is not thread safe.

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.