The ASP.NET UpdatePanel and Performance

I was chatting with someone at the event Mark and I did earlier today about the UpdatePanel in ASP.NET AJAX and I realised afterwards that I may have given a rather pessimistic view of performance so let me correct that here. The gentlemen was primarily concerned with network performance and optimising traffic.

As the UpdatePanel is optimised in the first instance for ease of use, I suggested that he may need to look beyond the UpdatePanel to other ASP.NET AJAX capabilities to tweak his app for optimum performance (eg using the web services support to call a web service and writing his own JavaScript on the client to update the UI - this gives you much more control and allows you to optimise the request / response). Of course there's always a trade-off - the UpdatePanel is a cinch to use but if you need that extra grunt then you'll want to take more direct control.

On the other hand, the UpdatePanel does a lot to improve matters over a page postback so you get a big benefit just from wrapping key elements to be updated in an UpdatePanel. eg, here's some data I just collected using Fiddler.

Postback
Viewstate Enabled Sent 5,514 Received 20,759
Viewstate Disabled Sent 1,019 Received 15,748
UpdatePanel Update
Viewstate Enabled Sent 5,461 Received
Viewstate Disabled Sent 886 Received

This data was collected using a DataList page from my demo site where I bind a DataList to some XML data. In the AJAX Callback version I dynamically render UpdatePanels for each of the "Price" fields in the ItemTemplate (the DataList is rendering some stock info such as high / low / current price etc)

So you get a significant gain by just introducing ASP.NET AJAX and the UpdatePanel and if you need to you can take this even further by tapping into lower-level features of ASP.NET AJAX such as web services support or the network stack.

Technorati tags: microsoft, ajax, asp.net, updatepanel