Saturday, February 19, 2011

ASP.NET Session State Migration

I was hoping someone could validate my assumptions before I recommend that my client upgrade from a 30/mo to a 80/mo hosting package.

Site: the site is a custom ASP.NET ecommerce site. the shopping carts are stored in the inproc session.

Problem during busy seasons like we are having now, users are frequently losing their shopping carts and their FormsAuthentication Login information.

Solution I wanted to migrate the site to use a SQL Server Session state. My assumptions are that the customers are losing their shopping carts because the InProc sessions are recycling more frequently then their 20 minute timeout, due to load. Will moving the Session to SQL Server or a Session State Server allow customer to store their Shopping Cart Session without the recycle, If so, can once their will I have any issues if I increase the Session timeout to say 40 or 60 minutes

From stackoverflow
  • The assumptions sound reasonable to me. might also want to look at the settings on the AppPool and try to figure out why its recycling. Maybe all you need to do is change those (if you can).

    bendewey : I'm on a very strict shared hosting, the reason for the upgrade would move me to my own personal Virtual Private Server.
    Greg Dean : I was afraid of that...
  • Could you just add some RAM to the box? That might help and would likely be cheaper and simpler than moving the session to SQL Server. Of course, it would only be a stopgap, but if it saved them $50/mo for a few years it's probably worthwhile.

    You might also check the code to see if some other data is left in the session for much longer than necessary.

  • Using the SQL Session state means that sessions should survive a recycle of IIS, (but not a recycle of SQL Server if you use the default script which creates the session database in the tempdb).

    There is a script available from the Microsoft website which creates a permanent session state db. I would recommend using that one instead (See here).

    So, to basically answer your question. Yes, the SQL Session state will help. You might want to consider also using the out-of-proc state server to test your theory.

    Also, as a co-worker has just reminded me, make sure anything you store in the session is marked as serializable before migrating, otherwise you will run into problems.

0 comments:

Post a Comment