This
enables you to decide where you need sessions to be reside.
InProc
InProc
- InProc, state is maintained within the managed memory of the ASP.NET process
- Storage location: Session kept as live objects in web server (aspnet_wp.exe). Use "cookieless" configuration in web.config to "munge" the sessionId onto the URL (solves cookie/domain/path RFC problems too!)
- Session will reside on same computer memory where web application deployed
- Session data is stored in current application domain and so consumes memory of server machine
- In case of server restarts, all session data is lost.
- Performance: Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.
- Robustness: 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.
OutProc
mode (which is generally State
Server or SQL Server)
OutProc
mode session is managed by an external resource (State Server or SQL Server)
Performance:
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.
State Server
- Storage location: Session serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine.
- Session will reside on other computer memory. you can specify the IP address of the PC.
- Session data is stored on state server and so web servers memory is not consumed.
- In case of web server restart, session data is preserved.
- Robustness: 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
- Storage location: Session serialized and stored in SQL server
- Session will be stored SQL server tables
- When storing data of basic types
- Performance: string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about serialization as in StateServer.
- Robustness: imilar 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
Considering
above points, use of session mode is the choice to be made considering load,
no. of users, performence requirment etc.
for small web site with limited no. of users, in-proc mode is best suited.
for large applications with huge no. of users, state-server/sql server session mode should be used.
for small web site with limited no. of users, in-proc mode is best suited.
for large applications with huge no. of users, state-server/sql server session mode should be used.
No comments:
Post a Comment