By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,164 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

Multiple threads or app instances?

P: n/a
ASP.NET QuickStart Tutorial says that:
....
ASP.NET maintains a pool of HttpApplication instances over the course of a
Web application's lifetime. ASP.NET automatically assigns one of these
instances to process each incoming HTTP request that is received by the
application. The particular HttpApplication instance assigned is responsible
for managing the entire lifetime of the request and is reused only after the
request has been completed. This means that user code within the
HttpApplication does not need to be reentrant.
....
A Note on Multiple Threads

If you use objects with application scope, you should be aware that ASP.NET
processes requests concurrently and that the Application object can be
accessed by multiple threads....
To make this code thread safe, serialize the access to the Application
object using the Lock and UnLock methods.
....

What do all above mean? ASP.NET/IIS launches multiple web applications for
every
request/session or one application (which starts when first request comes)
with multiple threads where each thread is responsible for each
request/session?
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Tumur:

On Fri, 1 Jul 2005 17:10:01 +0900, "Tumurbaatar S."
<sp********@magicnet.mn> wrote:

What do all above mean? ASP.NET/IIS launches multiple web applications for
every
request/session or one application (which starts when first request comes)
with multiple threads where each thread is responsible for each
request/session?


No, ASP.NET doesn't launch an application for every request.
HttpApplication is a poor choice for the name of the class - it
doesn't really represent an 'application'. ASP.NET will create a bunch
of these objects, and keep them in a 'pool', and each time a request
arrives one will get pulled out of the pool and associated with the
request.

I have some more information in an article, with additional links at
the bottom:
http://odetocode.com/Articles/89.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 19 '05 #2

P: n/a
one application (which starts when first request comes)
with multiple threads where each thread is responsible for each
request/session? Actually, one application object. The threads are not owned by the
application object. The threads belong to the application pool which is
owned by the CLR (50 threads per cpu i believe). 1/2 of these threads are
responsible for servicing http requests.

The re-entrancy part has to do with the fact that an IIS request is
guaranteed to be serviced by one httpapplication instance - a queue. So
there is no need to protect against concurrent access.
If you use objects with application scope This really isn't related to the http/IIS request portion of the
explanation.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
"Tumurbaatar S." <sp********@magicnet.mn> wrote in message
news:uU*************@TK2MSFTNGP15.phx.gbl... ASP.NET QuickStart Tutorial says that:
...
ASP.NET maintains a pool of HttpApplication instances over the course of a
Web application's lifetime. ASP.NET automatically assigns one of these
instances to process each incoming HTTP request that is received by the
application. The particular HttpApplication instance assigned is
responsible for managing the entire lifetime of the request and is reused
only after the request has been completed. This means that user code
within the HttpApplication does not need to be reentrant.
...
A Note on Multiple Threads

If you use objects with application scope, you should be aware that
ASP.NET processes requests concurrently and that the Application object
can be accessed by multiple threads....
To make this code thread safe, serialize the access to the Application
object using the Lock and UnLock methods.
...

What do all above mean? ASP.NET/IIS launches multiple web applications for
every
request/session or one application (which starts when first request comes)
with multiple threads where each thread is responsible for each
request/session?

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.