I am reviewing a web app is 90% complete but it’s terribly slow, even in a local environment (web server and DB) a transaction can take anywhere from 5-10 seconds to complete. The reason for this latency is that it uses updatepanels all over the place, I mean in 99.9% of all DB interactions. What options do I have to speed up this app without having to rewrite the entire application? I mean I don’t mind changing a few things here and there but there is a lot of functionality that is dependant on these transactions (updatepanels).
Your question is a bit unclear on what's going on within the updatepanels. Updatepanels themselves don't usually talk with DB or cause any spesific slowdowns.
You should profile the sql queries that each page load makes (either use sql profiler, some .NET profiler or just put timers around your most common sql queries).
If you're using Firefox and Visual Studio webserver, you might want to disable ipv6 in Firefox. You can do this by typing about:config if address bar and change the value of "network.dns.disableIPv6" to "true".
There's a good article by Dave Ward on optimizing UpdatePanels. There are to major hints you should understand and use:
- Page is reloaded completely even if only one UpdatePanel is actually changed. To optimize you can use
Request["__EVENTTARGET"] == UpdatePanel1.ClientID
hint described in article. - Use
PreRender
event to actually fill panels with data. Thus you'll avoid unnecessary data loading.
But if you have system that'll go under heavy load in future, it would be better to design it using web services but not update panels.
From experience, ViewState has the biggest impact on performance of UpdatePanels and AJAX in general, since each time there is a round trip all data in the ViewState must be serialized and packaged up into XmlHttpRequest(s) and sent across the wire.
Reduce ViewState as much as possible (turn it off for controls such as labels which are defined on the aspx page and won't be changing during round trips - Set property
EnableViewState="False"
on these)Minimize the scope of the UpdatePanels. By this I mean reduce the number of controls within the panels as much as possible. If certain controls do not need to be updated during ajax requests, get them out of the UpdatePanels to reduce the client-side overhead.
Consider the fact that by default UpdatePanels are "connected" meaning that during each round trip, ALL of the UpdatePanels will run through their update functionality even if only a single panel needed to change. To get around this try using the
UpdateMode="Conditional"
property. Then you are forced to trigger multiple panels to update only when it's necessary.
There is a good discussion of UpdatePanel usage here: http://stackoverflow.com/questions/72541/one-update-panel-vs-multiple-update-panels
In general, I would agree with others that it seems like AJAX may not be your only issue. You may want to profile the application and database performance to ensure your focusing in the right area.