Tuesday, January 22, 2013

Session State Management Strategies

There are two types of session state management strategy
  1. In Process
  2. out of process
In process – Stores session data on the same server.
Out of process – Stores data on other server like sql server, state server.


1. In process
Its best to choose when requests to come to same physical server rather than split to multiple IIS machines.
Its very fast and easy to implement because it runs in process.
Its wrong choice if your session state data is expensive to rebuild because when ever ASP.Net worker process or IIS restarts data flushes and rebuilds.
In case of multiple server its unsuitable until you implement some form of servers affinity like ‘network load balancing’.
2. Out of process
A. State Server – Its relies on a windows service, which remains stopped by default. You can start it from administrative tools / services / ASP.Net state service.
You can run it on same web server or can have a different ‘state server’ associated with your web server. It runs separately from IIS.
Beneficial is that you can restart IIS your session state data will not loss.
It require plenty of RAM because it runs separately from IIS.
Losses session state data on restart of server.
B. Sql Server - Stores data in table.
Its more reliable and flexible option than other.
You can restart server without losing data, you can even backup session state data.
Its also most expensive to build and maintain.

No comments:

Post a Comment

CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...