I'm wondering how the concurrency in a web application actually works. Ive read several articles and to my understanding multiple instances of HttpApplication would be working at the same time. Now, I created a simple web app to test concurrency and put the following to global.asax:
protected void Application_BeginRequest(object sender, EventArgs e)
{
Response.Write("Request started: " + DateTime.Now);
System.Threading.Thread.Sleep(10000);
Response.Write("<br />");
Response.Write("Request ended: " + DateTime.Now);
Response.End();
}
I was expecting that if I browse to the web app root in several browser tabs at nearly the same time, they would start and stop concurrently. However, it seems that they don't. Second tab start time is same as first time end time. I then tested by having this same code in an httpmodule or default.aspx page_load and got the same result.
What is going on here? Why aren't the requests being served parallel?
Edit: I'm placing my understanding mainly to two articles:
http://msdn.microsoft.com/en-us/magazine/cc188942.aspx says "If multiple requests targeting the same application arrive simultaneously, multiple HttpApplication objects will be used."
and http://www.code-magazine.com/article.aspx?quickid=0511061&page=5 has an example for an aspx page doing basically what I tested, with comment "Simulate slow request so we can see multiple requests side by side." next to Thread.Sleep call
It is possible that I'm completely misunderstanding something... but what?
http://www.code-magazine.com/article.aspx?quickid=0511061&page=5