2
votes

Which session mode in the following ,should i implement for my ASP.Net website?

1)InProc . 2)State Server. 3)SQL Server. 4)Custom.

3
It's impossible to answer this question without knowing more information about the system and how it is to be deployed. What are your requirements?pmarflee

3 Answers

4
votes

It depends entirely on your circumstances and the type of website you wish to operate.

I suspect your expected volumes of traffic and the hardware it is running on is also a large factor.

Can you give us more information.

Performance considerations

  • InProc - Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.

  • StateServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you're storing lots of objects. You have to do performance testing for your own scenario.

  • SQLServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about serialization as in StateServer.

Robustness

  • InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is stored in the memory space of an appdomain. For details, see KB324772.

  • StateServer - Solve the session state loss problem in InProc mode. Allows a webfarm to store session on a central server. Single point of failure at the State Server. SQLServer - Similar to StateServer. Moreover, session state data can survive a SQL server restart, and you can also take advantage of SQL server failover cluster, after you've followed instructions in KB 311029.

The above is an extract from an article by Peter A. Bromberg available here

0
votes

There's no one clear answer. It depends on how your app works, how many servers you have, what your tolerance for failure is etc. I would read up on the differences and then make an informed choice.

Providing you make everything that you are storing in the session serializable from the beginning, it is usually fairly easy to switch from one mode to another, unless you are using things like the Session_End event, which only fires when using in proc mode.

0
votes

The default is InProc, and that works fine for most small and moderate size web sites. You just use it, you don't have to implement anything at all.

If you have any special curcomstances, like load balanced servers or extreme amounts of users, you would need some of the other methods.