Session state modes and their advantages and disadvantages.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bharathreddy
    New Member
    • Aug 2006
    • 116

    Session state modes and their advantages and disadvantages.

    Here I will discuss about the advantages and disadvantages of types of session states available in asp.net.

    Why Session?
    HTTP is a stateless protocol. Each request is serviced as it comes; after the request is processed, all of the data is discarded. No state is maintained across requests even from the same client.

    However, it is very useful to maintain state across requests for certain solutions. ASP.NET enables you to maintain both application state and session state through use of application and session variables respectively.

    How ever I am not going to discuss about application state here as this article
    is on the session state management.

    Session State Modes:
    1) InProc (Provider: In-Memory Object) --More Fast
    2) StateServer (Provider: Aspnet_state.ex e) --Faster than Sql Server
    3) SqlServer (Provider: Database) --Slower than above modes
    4) Custom (Provider: CustomProvider)

    1) Advantages and Disadvantages on using InProc state management mode:
    Advantages :
    •There is not requirements of serialization to store data in InProc Session Mode.
    •It store Session data in memory object of current application domain. So accessing data is very fast and data is easily available.
    •Implement ation is very easy, just similar to using View State.

    Disadvantages :
    •Although InProc Session is fastest, common and default mechanism, It has lots of limitation.
    •If the worker Process or application domain recycles all session data will be lost.
    •Though its fastest, but more session data and more users can affects performance, because of memory.
    •we can't use it in web Garden scenarios .
    •This session mode is not suitable for web farm scenarios also.

    So as per above discussion, we can conclude InProc is very fast session storing mechanism but suitable for small web application. InProc Session Data will get lost if we Restart the server, application domain recycles It is also not suitable for Web Farm and Web Garden Scenarios.

    2) Advantages and Disadvantages on using State Server state management mode:
    Advantages :
    •It is useful in web farm and web garden scenarios.
    •Its keeps the data separate from IIS so, any Issue with IIS does not hamper Session data.

    Disadvantages :
    •State Server always need to be up and running.
    •Process is slow due to Serialization and De-Serialization


    3) Advantages and Disadvantages on using Sql Server state management mode:
    Advantages :
    •Session data do not affected if we restart the IIS.
    •It is the most reliable and secure session management.
    •It keeps data located centrally , It can be easily accessible from other application.
    •It is very useful in web farm and web garden scenarios.

    Disadvantages :
    •Processin g is very slow in nature.
    •Object serialization and de-serialization creates overhead for application.
    •As the session data is handled in different server, so we have to take care of SQL server. It should be always up and running.


    4) Before discussing on advantages and disadvantages on Custom state management, lets talk about when do we go for custom state management.

    we can use custom session mode in following of the cases:
    •When we have to use some Existing table to store session data.
    •When we need to create our own session ID.
    •We want to store session data rather than SQL Server.

    Advantages :
    •We can use some existing Table for the store session data, It is useful when we have to use some old database rather than SQL Server.
    •It's not depending on IIS , So Restarting web server does not make any effects on session data.
    •We can crate our own algorithm for generating Session ID.

    Disadvantages :
    •Processin g of Data is very slow.
    •Creating a custom state provider is a low-level task that needs to be handled carefully to ensure security.

    Thanks
    Bharath Reddy VasiReddy
Working...