Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - Which session state is best to use

 
Thread Tools Search this Thread
Old 03-14-2005, 11:37 PM   #1
Default Which session state is best to use


I am running with Sql Server and am curious if I should use in-process,
State Server, or SQL Server.

By default, I assume I am using in-process (I could be wrong here, however).
I am not actually defining it in my web.config.

I was thinking about moving to Sql Server mode, but am not sure what I would
gain or lose by changing.

One thing I was curious about, was if this would make it easier to figure
out who was using our system at any particular time (their sessions haven't
timed out yet).

Thanks,

Tom




tshad
  Reply With Quote
Old 03-15-2005, 02:27 AM   #2
Alvin Bruney [ASP.NET MVP]
 
Posts: n/a
Default Re: Which session state is best to use
There is no right answer for this, rather there are recommendations based on
your requirements. If you move to sql server session, you incur a
performance penalty but you also get to use session in webfarms and gardens.
In proc is the default mode by the way, as defined in the web config file.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


"tshad" <> wrote in message
news:...
>I am running with Sql Server and am curious if I should use in-process,
>State Server, or SQL Server.
>
> By default, I assume I am using in-process (I could be wrong here,
> however). I am not actually defining it in my web.config.
>
> I was thinking about moving to Sql Server mode, but am not sure what I
> would gain or lose by changing.
>
> One thing I was curious about, was if this would make it easier to figure
> out who was using our system at any particular time (their sessions
> haven't timed out yet).
>
> Thanks,
>
> Tom
>





Alvin Bruney [ASP.NET MVP]
  Reply With Quote
Old 03-15-2005, 02:37 AM   #3
Brock Allen
 
Posts: n/a
Default Re: Which session state is best to use
Two things:

1) I'd suggest not using Session state at all if you can avoid it. This isn't
always possible, but you avoid some types of problems later on if you can.

2) If you are going to use it, then don't accept the default of InProc. The
primary reason is that your worker process and/or AppDomain (essentially
the two different hosting environments) recycle very often (more than you'd
think) and as a side effect your in memory state (read: InProc Session State)
will be lost. It's odd, IMO, that this is even an option in ASP.NET. So,
in short: never use InProc Session State and configure it to be out of process.

-Brock
http://staff.develop.com/ballen



> I am running with Sql Server and am curious if I should use
> in-process, State Server, or SQL Server.
>
> By default, I assume I am using in-process (I could be wrong here,
> however). I am not actually defining it in my web.config.
>
> I was thinking about moving to Sql Server mode, but am not sure what I
> would gain or lose by changing.
>
> One thing I was curious about, was if this would make it easier to
> figure out who was using our system at any particular time (their
> sessions haven't timed out yet).
>
> Thanks,
>
> Tom
>






Brock Allen
  Reply With Quote
Old 03-15-2005, 04:46 PM   #4
Alvin Bruney [ASP.NET MVP]
 
Posts: n/a
Default Re: Which session state is best to use
>It's odd, IMO, that this is even an option in ASP.NET. So, in short: never
>use InProc Session State and configure it to be out of process.

It's not odd. Recycling application promotes greater stability and immunity
towards errant processes leaking memory among other things. There is a
reason why inProc is the default mode, because it works best for a large
number of applications. If you recommend switching modes, you should have a
sound reason and thoroughly understand the consequences such as performance
degradation occuring when session passes thru the
serialization/deserialization layer.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


"Brock Allen" <_hate_spam_too> wrote in message
news:.. .
> Two things:
>
> 1) I'd suggest not using Session state at all if you can avoid it. This
> isn't always possible, but you avoid some types of problems later on if
> you can.
>
> 2) If you are going to use it, then don't accept the default of InProc.
> The primary reason is that your worker process and/or AppDomain
> (essentially the two different hosting environments) recycle very often
> (more than you'd think) and as a side effect your in memory state (read:
> InProc Session State) will be lost. It's odd, IMO, that this is even an
> option in ASP.NET. So, in short: never use InProc Session State and
> configure it to be out of process.
>
> -Brock
> http://staff.develop.com/ballen
>
>
>
>> I am running with Sql Server and am curious if I should use
>> in-process, State Server, or SQL Server.
>>
>> By default, I assume I am using in-process (I could be wrong here,
>> however). I am not actually defining it in my web.config.
>>
>> I was thinking about moving to Sql Server mode, but am not sure what I
>> would gain or lose by changing.
>>
>> One thing I was curious about, was if this would make it easier to
>> figure out who was using our system at any particular time (their
>> sessions haven't timed out yet).
>>
>> Thanks,
>>
>> Tom
>>

>
>
>





Alvin Bruney [ASP.NET MVP]
  Reply With Quote
Old 03-15-2005, 05:42 PM   #5
Brock Allen
 
Posts: n/a
Default Re: Which session state is best to use
> It's not odd. Recycling application promotes greater stability and
> immunity towards errant processes leaking memory among other things.


Yes, of course. And that's why this is a welcome feature.

> There is a reason why inProc is the default mode, because it works
> best for a large number of applications. If you recommend switching
> modes, you should have a sound reason and thoroughly understand the
> consequences such as performance degradation occuring when session
> passes thru the serialization/deserialization layer.


I think the vast majority people don't "thoroughly understand the consequences"
of leaving session state at InProc. The AppDomain/worker process recycle
a heck of a lot more than people realize and if your app relies upon session
state, then the robustness of keeping the data out of proc is the price to
be paid. As I said in my earlier post, I recommend avoiding session state
all together if possible.

But the reality is that most performance problems come from bad SQL and inefficient
trips to the database. Of course there is overhead to the StateServer Service
but if you're using InProc session state, then you'd only be making a cross
process call, as the StateServer Service would/should be configured on the
same machine. The overhead of the local access to the StateServer is dwarfed
by the network latency of hitting the DB.

As with anything, understand what you're doing. As far as performance, correctness
comes first. Don't optimize until you've profiled.

-Brock
DevelopMentor
http://staff.develop.com/ballen





Brock Allen
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[newbie] Session state can only be used when enableSessionState is set to true jon80 Software 0 03-08-2009 05:40 PM
Using BRAM in state machines zoki111 Hardware 0 09-18-2007 09:38 AM
Transfering ASP Session to ASPX Session kalim Software 0 07-12-2007 03:38 AM
Judge: File-swapping tools are legal Citizen Bob DVD Video 140 11-08-2006 06:42 PM
BUSH WILL LIKELY INSTALL A DRAFT Jas DVD Video 165 10-20-2004 09:39 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46