Reputation: 3168
First things first, Hope you all have a good Christmas :)
I've been a desktop application developer for the last couple of years but I'm now working on ASP.NET full time (job move :) )
So over the last few days, I've found my self wondering more and more about what actually happens when say a new visitor will visit my URL..
I've just been working on quite a simple Signal R based app and I have needed a few singletons to be shared across all sessions, now in desktop that's super simple but I'm not sure with the web at all :(
So basically, here is this question..
What actually does IIS do when say 5 people visit my URL, do they all get a separate instance of the app or do they use the same one? If you could break it down into simple terms, that would be fantastic! :)
Also, Say I've got a class library that has a static singleton - with that be the only instance of that class for the all the sessions?
Hopefully that makes sense :)
Thanks for any help!
cheers. ste.
Upvotes: 3
Views: 158
Reputation: 561
If you have a default IIS install then you will have one app pool which will serve all requests. Therefore a static singleton will be shared by all 5 people in your example.
BUT if you ever need to scale out then you will have multiple app pools.
An app pool is an instance of your application.
If the statics are for database connections and similar then I would suggest you look at alternative methods so you don't need the statics. If it is something related to the business that your users are interested in then you would be best looking at other ways to share this between clients if you are going to need to scale.
Upvotes: 1
Reputation: 66649
This is called IIS Life Cycle
The fully details must be direct read from Microsoft and the creators of the IIS.
Is not the same for all IIS.
Life Cycle Overview for IIS 7.0
Life Cycle Overview for IIS 5.0 and 6.0
and there are more if you search on internet.
do they all get a separate instance of the app or do they use the same one
If you use many pools for the same application (web garden) then they the request are split among the pools, or else one pool, one instance is take care to process the page.
The page can be processing from different threads, but there is a global lock on the session, so if you use the MS session the page will processing in serial (expect the one that did not use session)
Each pool is one instance that hold the static data, and is the same for all request from that pool. If you use two pools you have two different sets of static data.
Some questions about session lock: Trying to make Web Method Asynchronous , Web app blocked while processing another web app on sharing same session
Upvotes: 1