views:

87

answers:

4

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

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

+2  A: 

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

Martin
A: 

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.

RichardOD
+1  A: 

Only you can answer that question, by understanding the differences betwen the various modes, and knowing what your application needs:

http://msdn.microsoft.com/en-us/library/ms178586.aspx

MikeB
A: 

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.

Guffa