![]() |
|
|
|
#1 |
|
I'm interested in seeing a bit of discussion about using singletons in
ASP.NET 2.0. Currently I've designed a singleton that gets a reference to it's single instance stored inside the ASP.NET application object. This is done to persist and make available live information across multiple sessions. I've read a little bit (almost nothing) about how singletons don't play nicely in clustered scenarios and would like to hear more on the subject. As mentioned above, my class is only a singleton because it's only reference is stored in the application object. Because of this, I could just as easily NOT write singleton and simply instantiate the same object in the same place as where I'm storing the reference (application handler on application start). >From what I can see, the application object is the only place ASP.NET makes available a facility to put code that lives throughout the application. How does clustering really impact a singleton or a single instance of a class stored in the application object? Omega |
|
|
|
|
#2 |
|
Posts: n/a
|
the impact of a cluster on a singleton depends on the functionality of the
singleton. if the singleton is a cache of read only data, then there is none. if the singleton is a cache of realtime data coming from the web site, then there is. say you singleton was a counter of logged in users implemented as a static counter. a version of the counter would exist on each cluster member, and updating one has no effect on the others. you would then have to write code so that the singltons updated each other. any class can implement the singleton pattern thru the static (shaed in vb) methods or properties. -- bruce (sqlwork.com) "Omega" <> wrote in message news: oups.com... > I'm interested in seeing a bit of discussion about using singletons in > ASP.NET 2.0. > > Currently I've designed a singleton that gets a reference to it's > single instance stored inside the ASP.NET application object. This is > done to persist and make available live information across multiple > sessions. > > I've read a little bit (almost nothing) about how singletons don't play > nicely in clustered scenarios and would like to hear more on the > subject. > > As mentioned above, my class is only a singleton because it's only > reference is stored in the application object. Because of this, I > could just as easily NOT write singleton and simply instantiate the > same object in the same place as where I'm storing the reference > (application handler on application start). > >>From what I can see, the application object is the only place ASP.NET > makes available a facility to put code that lives throughout the > application. > > How does clustering really impact a singleton or a single instance of a > class stored in the application object? > bruce barker \(sqlwork.com\) |
|
|
|
#3 |
|
Posts: n/a
|
Application state is per-worker process. Which means a cluster of 2 or more
servers will each have their own application state. This means you can't have true singletons by using the Application object. If you need a true singleton, you need to find a way to share it across each server. A somewhat complicated but highly efficient way is to use .NET Remoting. Karl -- http://www.openmymind.net/ http://www.fuelindustries.com/ "Omega" <> wrote in message news: oups.com... > I'm interested in seeing a bit of discussion about using singletons in > ASP.NET 2.0. > > Currently I've designed a singleton that gets a reference to it's > single instance stored inside the ASP.NET application object. This is > done to persist and make available live information across multiple > sessions. > > I've read a little bit (almost nothing) about how singletons don't play > nicely in clustered scenarios and would like to hear more on the > subject. > > As mentioned above, my class is only a singleton because it's only > reference is stored in the application object. Because of this, I > could just as easily NOT write singleton and simply instantiate the > same object in the same place as where I'm storing the reference > (application handler on application start). > >>From what I can see, the application object is the only place ASP.NET > makes available a facility to put code that lives throughout the > application. > > How does clustering really impact a singleton or a single instance of a > class stored in the application object? > Karl Seguin [MVP] |
|
|
|
#4 |
|
Posts: n/a
|
VERY informative from both of you. Thank you.
Understanding more how the pages work as a process on the system certainly paints a clearer picture. Having not read a book on running ASP.NET 2.0 sites, I can't really make any guesses on how it would behave. Can either of you reccomend a book that covers the insides & outs of the MS application server? I'm interested in learning every little detail to ensure that my programs are well tuned. Omega |
|
|
|
#5 |
|
Posts: n/a
|
Best online Searchable book is Google, but stay away from Booble
SA "Omega" <> wrote in message news: oups.com... > VERY informative from both of you. Thank you. > > Understanding more how the pages work as a process on the system > certainly paints a clearer picture. > > Having not read a book on running ASP.NET 2.0 sites, I can't really > make any guesses on how it would behave. > > Can either of you reccomend a book that covers the insides & outs of > the MS application server? I'm interested in learning every little > detail to ensure that my programs are well tuned. > MSDN |
|
|
|
#6 |
|
Posts: n/a
|
I find that online searches don't always result in the structure and
focus needed to cover something with as many facets as IIS & ASP.NET 2.0 administration. Looking at the snap-in, I can see many things that could be done great justice with some explanation. Omega |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| viewstate MAC failed in asp.net 2.0 while postback the page | azraffarveen | Software | 0 | 05-12-2009 03:24 PM |
| .NET 2.0 Web Apps / .NET 3.5 ASP.NET Apps - Differences/Similariti | london1919 | MCTS | 1 | 12-08-2008 03:16 PM |
| ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) | msandlana | Software | 0 | 04-25-2008 06:37 AM |
| session from asp to asp.net | imman | General Help Related Topics | 0 | 02-20-2008 06:27 PM |
| ASP.NET 2.0 application does not run in WIN2k3 | johnfraj | Software | 0 | 04-19-2007 08:27 AM |