InProc Session or save to database (using EF4.1)

While rebuilding a site I'm having a rethink on various aspects of my site.

One thing my current site does is store the shopping cart in session (InProc) through the various page requests of the buy process.

I'm thinking of moving away from using the session state and instead saving the cart to a database using Entity Framework where necessary.

Will I see a massive impact on performance in storing the cart this way?


You probably won't notice any performance difference by using a database to store your cart. The plus point is that should your site take off and you get 10,000 hits a day your app will be able to scale :)

Is there a performance hit for storing data in the database? Yes. Are your users likely to notice? Probably not. Can this and all of the other little data calls your application makes add up to a noticeable difference to your users? Definitely. Like most everything, you need to balance the needs, benefits and resources.

I would first ask why you want to store your shopping cart in the database. The reasons that jump to mind include web farm scenarios and persistence in case of w3wp resets or failures.

There are a few solutions for the web farm scenario: out-of-process session mode, database session mode, or use sticky sessions with in-process mode. Check out the ASP.NET session modes for more info.

If all you're trying to do is persist your cart or protect it from in-memory volatility, you could just move your session state to the database as a quick to implement solution, but you could also go to explicit database tables. Size of session, size of shopping cart data, network and hardware performance and many other aspects of your system could affect your results. So measure, change, measure, compare.

Need Your Help

Convert molten data frame to matrix in R

r matrix data.frame reshape2

I would like to write a function that converts a data frame into a matrix. The data frame is a list of events. Each row corresponds to a person visiting or buying the product.

How does one create a package for a Java Project through the Unix command-line?


How does one create a package for a Java Project through the Unix command-line?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.