Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pros and Cons of using ASP.NET Session State Server (instead of InProc)?

Tags:

Before I start using Session State server for the benefit of making session state more robust in my apps compared to InProc state, I'd like to find a list of Pros and Cons for evaluation.

Update 1: Also about surviving application pool recycles?

Update 2: What about longevity of sessions and their endings?

like image 868
John K Avatar asked Apr 26 '10 14:04

John K


People also ask

What is the disadvantage of session state?

The disadvantages of using session state are: - Since data in session state is stored in server memory, it is not advisable to use session state when working with large sum of data. Session state variable stays in memory until you destroy it, so too many variables in the memory effect performance.

What is the difference between ASP session state and ASP.NET session state?

In Asp, the session is process dependent . That is, Asp session state is dependent on IIS process very heavily. So if IIS restarts Asp session variables are also recycled. Whereas In Asp.Net, the session is process independent .

Which is better ViewState or session?

The basic difference between these two is that the ViewState is to manage state at the client's end, making state management easy for end-user while SessionState manages state at the server's end, making it easy to manage content from this end too. ViewState: It is maintained at only one level that is page-level.


1 Answers

Here's the canonical analysis of the pros and cons of your three options, from Rob Howard's ASP.NET Session State article:

  • In process. In process will perform best because the session state memory is kept within the ASP.NET process. For Web applications hosted on a single server, applications in which the user is guaranteed to be re-directed to the correct server, or when session state data is not critical (in the sense that it can be re-constructed or re-populated), this is the mode to choose.

  • Out of process. This mode is best used when performance is important but you can't guarantee which server a user will request an application from. With out-of-process mode, you get the performance of reading from memory and the reliability of a separate process that manages the state for all servers.

  • SQL Server. This mode is best used when the reliability of the data is fundamental to the stability of the application, as the database can be clustered for failure scenarios. The performance isn't as fast as out of process, but the tradeoff is the higher level of reliability.

The out-of-process (aka "StateServer") and SQL-Server options both survive web application restarts (including application pool cycling) and both make session data available to multiple servers in a cluster / farm.

Finally, it may go without saying, but the basic in-process setup is the easiest to configure, which is a meaningful "pro" in many environments.

Tim Sneath's ASP.NET Session State: Architectural and Performance Considerations adds some additional information, and the MSDN topic on Session State Modes is a reliable, up-to-date source.

like image 156
Jeff Sternal Avatar answered Oct 16 '22 15:10

Jeff Sternal