Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Session State Server vs. InProc Session

What is the overhead performance penalty for running Session State Server instead of InProc? Is it significant? I understand that you can restart w3wp with the state server and retain all session state - is that the only advantage over InProc?

like image 839
Alex Avatar asked Sep 16 '09 08:09

Alex


People also ask

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

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 . That is, Asp.Net session can be independent of the hosting environment thus Asp.Net session can maintained even if IIS reboots.

What is session state mode InProc?

InProc session mode indicates that session state is stored locally. This means that with InProc session state mode is stored as life objects in the AppDomain of the Web application. This is why the session state is lost when Aspnet_wp.exe (or W3wp.exe, for applications that run on IIS) or the AppDomain restarts.

Which is the best session state mode?

The InProc Session State Mode stores session data in a memory object in the application worker process (aspnet_wp.exe) in the application domain. It is usually the fastest, but more session data means more memory is used on the web server, and that can affect performance.

What is difference between state and session?

View state can only be visible from a single page and not multiple pages. Session state value availability is across all pages available in a user session. It will retain values in the event of a postback operation occurring. In session state, user data remains in the server.


1 Answers

It depends on your deployment plans: on a single server, the penalty is small, but the benefit is equally limited: your session state survives process recycles (as mentioned) but that's about it. You'll have some cross process marshalling with StateServer mode, so expect some additional cpu load, nothing too impressive.

In a web farm/load balanced setup InProc won't work, unless you can configure sticky sessions/server affinity. Be mindful of the fact that the StateServer node itself can become a single point of failure, so be sure to compensate for that. Having said that, the latency of a StateServer is in general much less (= better) than when you use SQLServer mode.

Make sure that your code/site gracefully handles lost state, regardless of where you store the data.

like image 190
tijmenvdk Avatar answered Oct 01 '22 08:10

tijmenvdk