The Perils of in-memory Sessions

The “usual” implications of in-memory session are fairly well-understood:

  • A user is tied to a machine, so if the machine dies, the session dies (To be more specific, a user is tied to the process that is serving the request, so if the process dies, the session dies as well – this is useful to keep in mind when having web gardening, with multiple processes serving up an IIS application pool.)
  • Load balancing may get skewed depending on how long a user’s session lives.

 However, when it comes to high availability setups, in-memory sessions have more than these basic implications. For one, availability is not just protecting against a machine going down, it is also protecting against a user’s session going down, especially if the session involves multi-step transactions. If you are looking for a 99.99% availability, you really do not want to have in-memory sessions.

Also combine that with when you have set up your IIS server to have app pool recycles. If a recycle happens while users are logged on to that machine, then all those users are presented with a logon dialog in the middle of their order confirmation and are going to be somewhat upset with you.

The other implication is how you upgrade high availability systems. Consider that I just want to make a simple web.config change to all my web servers. A change to web.config results in an app pool recycle, so any users who are logged on will get thrown out. So, if I do need to make this change, then I need to something like so:

  • Assuming you have a reasonable load balancer, configure it so that no new sessions are allowed into this server.
  • Twiddle thumbs till you see that there are no new requests on this server
  • Make the web.config change
  • Re-configure your load balancer to have traffic back into this machine
  • Repeat for all the machines in your farm.

And so, a simple web.config change which should have just been a couple of seconds to deploy is now suddently a few minutes, or a few hours.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: