Search code examples
asp.netsessioniissession-state

Is InProc Session State unstable under load


In this question there's a comment with a few upvotes that states:

InProc session state is known to be highly unstable under load. If it's abused (happens all the time), then Session["foo"] = null will perform better than Session.Remove["foo"]. The garbage collector should clean up the mess of excessive session variables

This concerns me as all of my web apps make heavy use of session state (account info, baskets, payment details, user preferences etc.).

I can't seem to find any evidence to back up this claim, can someone debunk this or explain why this is correct. Am I wrong to be storing such info in session? I'm not looking for a pros and cons of InProc vs SQL, I'm aware of the differences.

All of my apps run on a single or dedicated webserver so I've never seen any benefit or point in moving to SQL for session state.


Solution

  • InProc Session State is stable and you don't have to worry about it. I don't know why he called it unstable but I guess he might have thought one of the following reasons while commenting:

    • If your application gets too much load; when you scale it, you have to use sticky session (for InProc SessionState) to redirect the requests to the same server for a client otherwise session object would not persist.
    • If an application has memory leaks or inconsistencies, heavy load will most probably trigger the application to reset and this will cause all the session data be lost so that current users' active pages might get errors since their session datas are lost.
    • Session object is locked out for the entire request (for that user only) to prevent multiple pages to write into the session so that if concurrent requests are made for example, they have to wait for each other to write data into Session. But it happens both in SQL and InProc SessionState.

    I saw banking applications which work with InProc SessionState and there is nothing unstable about it.