ASP.NET: how concurrent requests are handled

Allows you to create images on a 2-page website: fast and slow. Slow page requests are completed within 1 minute; request fast 5 seconds.

My whole development career I thought that if the 1st request started slowly: it will make a (synchronous) call to DB ... wait answer ... If during this time a request for a quick page is executed, this request will be processed while the system expects a response from the database.

But today I found: http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx

One instance of the HttpApplication class is used to handle many requests throughout its life. However, it can only process one request at a time. Thus, member variables can be used to store data for a query.

Does this mean that my original thoughts are wrong?

Could you clarify what they mean? I am pretty sure that everything is as I expect ...

+6
parallel-processing msdn
source share
3 answers

Your initial thoughts are correct, and so is the documentation. An IIS workflow can spawn multiple threads, each with its own instance of the HttpApplication class.

+4
source share

ASP.NET will host multiple AppDomains for your web application as part of a single workflow (w3wp.exe). It can even share AppDomains for different web applications under the same workflow (if they are assigned to the same application pool).

Each AppDomain created by ASP.NET can contain multiple HttpApplication instances that serve requests and go through the ASP.NET lifecycle. Each HttpApplication application can (as you said) respond to one request at a time.

+4
source share

Requests should be processed sequentially on the server side if both requests use the same read / write session state due to an asp.net session lock.

You can find more information here: http://msdn.microsoft.com/en-us/library/ie/ms178581.aspx

Concurrent Queries and Session State

Access to the ASP.NET session state is exclusive for each session, which means that if two different users execute concurrent requests, access to each individual session is granted simultaneously. However, if two simultaneous requests are made for the same session (using the same SessionID value), the first request gets exclusive access to the session information. The second request is executed only after the completion of the first request. (A second session can also be accessed if the exclusive information lock is released because the first request exceeds the lock timeout.) If the EnableSessionState value in the @ page directive is set to ReadOnly, the read-only request for the session information does not result in an exclusive data lock. session. However, for read requests only for session data, it may be necessary to wait for the lock established by the read and write request to clear the session data.

+4
source share

All Articles