Re: Session Variables - Good or Bad

From: Harry Simpson (hssimpson_at_nospamphgt.net)
Date: 10/12/04


Date: Tue, 12 Oct 2004 15:21:19 -0500

I'm for knowledge here...no agendas...just want to understand and then
decide.

Harry

"Sahil Malik" <contactmethrumyblog@nospam.com> wrote in message
news:Ocr7VOJsEHA.2580@TK2MSFTNGP15.phx.gbl...
> Actually .. I respectfully disagree ;) .. don't take it personally . .!!
> :))
>
> - Sahil Malik
> You can reach me thru my blog at
> http://www.dotnetjunkies.com/weblog/sahilmalik
>
> "Sahil Malik" <contactmethrumyblog@nospam.com> wrote in message
> news:%2354c3KIsEHA.1036@TK2MSFTNGP10.phx.gbl...
>> Allright, I disagree .. Let me explain why ---
>>
>> >> As far as scalability, SqlServer mode scales very well and doesn't
>> >> rely
>> on a centralized model (no more so than any other SQL Server database).
>>
>> SqlServer scalability is acheived using failover and clustering. Not
>> using
>> Network Load Balancing and Web Farms (redundancy). Web farm machines are
> by
>> far much cheaper than Sql server clustering architecture. What's more, by
>> using Session variables and not specifying state server, you loose any
>> prayer of ever being able to use a webfarm well enough. Not to mention,
> you
>> have one point of failure, and hardware limitations on that one poor box
>> acting as the state machine. By using a state server you donot lock
> yourself
>> up into an app that will never scale - but you make it pretty damn
> expensive
>> to scale in future - which is the whole point, you want to acheive
>> scalability cheaply by adding/removing machines at runtime without
> bringing
>> the entire site down. (therefore www24.microsoft.com).
>>
>> >> What's even better is how easy it is to switch modes - so long as you
>> were careful to design all objects which are to be stored in sessions as
>> serializable (normally achieved simply by specifying the
>> ISerializableAttribute() to the class) you simply change your web.config
> and
>> off you go.
>>
>> Objects in session are even worse. If you have a memory leak, you just
>> fixated that memory leak in a process that won't die (IIS). Not to
>> mention
>> there is nothing like ISerializableAttribute, but there is a
>> SerializableAttribute and an ISerializable interface.
> SerializableAttribute
>> works .. well most of the times; but first of all it's behavior is
> limited,
>> (it's not that smart), and it has troubles with protected members and
>> delegates.ISerializable on the other hand depends on the programmer's
>> efficacy - which I try and not rely on in a website that is highload -
>> typically multi megabyte source code - you cannot practically enforce
>> good
>> programming all over.
>>
>> >> Finally, ASP.Net 2.0's provider model will provide even more choice.
>> Makes no difference to the above facts.
>>
>> The rule is - Try very hard to avoid session - but don't put yourself in
>> a
>> hospital trying to avoid it.
>>
>> - Sahil Malik
>> You can reach me thru my blog at
>> http://www.dotnetjunkies.com/weblog/sahilmalik
>>
>>
>>
>> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
>> wrote in message news:%23N3ZFFHsEHA.3848@TK2MSFTNGP14.phx.gbl...
>> > I disagree with the two answers given so far, sessions in ASP were evil
>> 'cuz
>> > they were stored in the same memory space as the worker process. This
> is
>> > true in ASP.Net as well when you have it set for InProc. It isn't true
>> for
>> > either StateServer or SQLServer. As far as scalability, SqlServer mode
>> > scales very well and doesn't rely on a centralized model (no more so
> than
>> > any other SQL Server database). What's even better is how easy it is
>> > to
>> > switch modes - so long as you were careful to design all objects which
> are
>> > to be stored in sessions as serializable (normally achieved simply by
>> > specifying the ISerializableAttribute() to the class) you simply change
>> your
>> > web.config and off you go.
>> >
>> > Finally, ASP.Net 2.0's provider model will provide even more choice.
>> >
>> > Karl
>> >
>> > --
>> > MY ASP.Net tutorials
>> > http://www.openmymind.net/
>> >
>> >
>> > "Sahil Malik" <contactmethrumyblog@nospam.com> wrote in message
>> > news:O53hT$GsEHA.3728@TK2MSFTNGP09.phx.gbl...
>> > > Session variables - bad.
>> > >
>> > > All the session state schemes rely on a centralized model - that can
>> never
>> > > be good for scaleability.
>> > >
>> > > But if it means you will have to write tonnes of code for a website
> that
>> > has
>> > > 5 concurrent users, then go ahead use 'em. (never overarchitect).
>> > >
>> > > - Sahil Malik
>> > > You can reach me thru my blog at
>> > > http://www.dotnetjunkies.com/weblog/sahilmalik
>> > >
>> > >
>> > > "Harry Simpson" <hssimpson@nospamphgt.net> wrote in message
>> > > news:%23pITF8GsEHA.760@tk2msftngp13.phx.gbl...
>> > > > I've come from the old ASP camp where session variables were not
> used.
>> > > When
>> > > > i started using ASP.NET in 2001, I started using them again because
> it
>> > was
>> > > > ok from what I'd read.
>> > > >
>> > > > I've been merrily using Session variables for three years now and
> i'm
>> > > > entering a project with my new boss who has never quite come around
>> that
>> > > > session variables are ok.
>> > > >
>> > > > What's the concensus here. How can i convince him that they are ok
> in
>> > > > ASP.NET. OR
>> > > >
>> > > > Are there those out there that still think they aren't good to use?
>> > > >
>> > > > TIA
>> > > >
>> > > > Harry Simpson
>> > > > MCSD
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
>
>



Relevant Pages

  • Re: SQL2005: shred the feeds or store as XML?
    ... My blog itself does not give you the answer :-). ... > the web; syndicated web feeds? ... Otherwise store it as XML in the ... >>> Looking for a SQL Server replication book? ...
    (microsoft.public.sqlserver.xml)
  • Re: ERROR - SQL Server 7, Reporting Services, and SQL 2000 Functions
    ... My .Net blog, ... > SQL7 did not support collations like SQL2000 does and the DATABASEPROPERTY ... > Kanatype sensitivity = false ... > Jasper Smith (SQL Server MVP) ...
    (microsoft.public.sqlserver.server)
  • Re: Combining many records into 1
    ... NoteID is the same for each complete blog record ... SeqNum ranges from 1 - 20 for each NoteDetailID ... SQL Server MVP Anith Sen as a couple of methods on ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Session Variables - Good or Bad
    ... > on a centralized model (no more so than any other SQL Server database). ... > ISerializableAttribute() to the class) you simply change your web.config ... > Objects in session are even worse. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Project server 2003 and SQL Server 2005 not a supported option !!
    ... statement regarding SQL Server 2005 support. ... If you want to test it, you can follow the blog posting. ... notice that the OLAP cube cannot build with SQL Server AS 2005. ... > this is not a supported fix and anyway, even if I apply the fix I then ...
    (microsoft.public.project.pro_and_server)