MVC vs WebForms

Whether you want to use MVC or WebForms as a starting point for your project is up to you, but we just want to highlight one benefit of using Commerce Server with WebForms; Queuing.

If you are developing a site in three-tier then network calls are enemy #1, every network call you have on a page load introduces a perf. impact. Commerce Server offers the ability to queue up as many requests as you like and send them all to the backend at once, this is a perf. life saver because now no matter how many CS calls you need to make, there will only be one call over the network.

So why is this a benefit for Webforms? Well because of its page event life cycle (which MVC does not have) it can take full advantage of queuing by doing something like this...
  • On the PreLoad event each page and control queues up any Commerce Server calls it needs to make
  • On the Load event each page and control asks for its results from the queue. The first one to ask for its results triggers the entire set of requests to be sent to the backend, get evaluated, and have their results returned.

As long as every page and control follows this pattern you can be sure that you will never be making more than one request across the wire for each page load. I picked PreLoad and Load above, but you can do it with any events, PreInit and Init will work just fine too.

With MVC you can still leverage queuing but only within a single controller. The problem with MVC is that there is no event life cycle, each controller runs start to finish before any other controllers in the request will run. Because of this there is no way for controllers to work together to queue up all of the data they need.

We are not trying to say that you shouldn't use MVC if you are building a three-tier site, we have achieved some really high perf. numbers with MVC and three-tier, we just want to make sure you fit queuing into your project in some way so you end up with the best perf numbers possible.

The request template service adapter has some very simple methods on it for queuing, but if you are using MCF calls on your site you will need to craft something yourself to hold the queue before you submit it to the backend.


Last edited Dec 11, 2012 at 8:14 PM by cmcauliffe, version 3

Comments

No comments yet.