Have you ever wondered why CodePlex is so slow?
AJAX, ASP.NET, Performance By Dave Ward on December 3rd, 2008It’s hard to believe that nearly two months have already passed since opening the doors on the Username Availability Validator project. I made a few mistakes in how I ran the project, but I’m happy with the overall outcome.
However, one thing that disappointed me throughout the entire contest was how slow CodePlex can be. Even as the single person most invested in the success of the project, I often found myself leaving the site in the middle of tasks, unwilling to endure the slowness. What’s worse, I also found myself procrastinating to avoid returning to CodePlex and dealing with these waits.
I’m not one to complain without offering some constructive criticism though. Especially since we’re talking about a completely free service.
I think the lesson to be learned here is something that many ASP.NET developers could benefit from. So, I’d like to take a look at one ASP.NET AJAX related inefficiency that I found on CodePlex and one potential alternative to it.
A specific example
To get a concrete handle on this, I’m going to focus on one function that’s in need of optimization: The Issue Tracker’s voting feature. In fact, there’s already a work item on CodePlex about this specific issue.
For example, this is the Issue Tracker for the ASP.NET project:

Its operation is straightforward. When you click a “vote” link, a partial postback is triggered to register your vote in the TFS backend, and then update the displayed votes tally.
You may have written similar code yourself, using UpdatePanels. I have too.
Unfortunately, this performs extremely poorly on a complex page. I’ve personally seen the round-trip time for a single CodePlex vote range anywhere from several seconds up to more than a minute.
I can’t imagine an argument for this being acceptable. When a system is that slow, your users learn not to bother attempting a potentially slow operation, and you’re left with pages of mostly single voted items, as seen on most CodePlex projects.
The Request: A big base64 blob
It seems like simple enough functionality, so why does it run so slowly?
A quick look at the HTTP traffic between the client and server is enlightening. This is the HTTP request that is generated when clicking a “vote” button:

17,358 bytes. Note that this is just the request to the server, not including the server’s response. You would hope that “vote++ for this issue” could be expressed more succinctly than 17k of base64 gibberish!
Even worse than actually transferring this bulk of data around, the server must also re-instantiate the Page and all of its controls based on this ViewState data, then run them all through their lifecycles.
In the end, all of these gyrations add up to a tremendous amount of overhead. In CodePlex’s case, these unnecessary Page instantiations are likely the true culprit.
The Response: Bigger is not better
Things only get uglier when the response comes back down from the server:

Not only does the response contain HTML markup to completely replace every one of the voting blocks, it also contains an updated ViewState field just as large as the request’s. So, this response is roughly as large as the entire request and the HTML in each UpdatePanel.
In this case, that weighs in at hefty 28,830 bytes.
Compared to transferring the ViewState up to the server and waiting on the server to completely re-instantiate and re-render the Page, the response’s payload isn’t as big a problem as its size implies. However, it certainly adds overhead.
It doesn’t have to be this way
There are significantly better ways to do this. Let’s take a look at how another site, Stack Overflow, handles the voting scenario.
For example, take a look at this Stack Overflow answer that I posted recently. If you click its up-vote arrow, an asynchronous POST request will be sent to this URL:
http://stackoverflow.com/questions/171014/vote
This POST request would contain only this data:
voteTypeId=2The resulting response? A compact JSON object indicating the result:
{"Success":true,"NewScore":2,"Message":"","LastVoteTypeId":2}
That’s it.
No HTML. No monstrous ViewState. No bloat. Oh, and the entire round-trip takes a fraction of a second instead of several to dozens of seconds.
Is this the answer?
Could CodePlex’s issue voting work like Stack Overflow’s? Absolutely!
The Stack Overflow vote feature is a request against an ASP.NET MVC controller action, but it could just as easily be implemented without MVC by using a web service. The ASP.NET AJAX client library (which CodePlex is already using) provides excellent support for calling ASMX or WCF services and handling their JSON result.
Allowing for testing and the inevitable complications that arise, CodePlex’s slow voting could probably be fixed in just a few hours.
Conclusion
We are generally presented with a wide array of methods for accomplishing a given task. Unfortunately, somewhere along the way we’ve acquired this faulty attitude that, as long as they get the job done, all methods are roughly equivalent.
These two voting implementations are a great example of the fallacy in that line of thinking. Both solutions are similarly complex and function correctly, yet differ in performance by orders of magnitude.
I hope seeing the massive difference in black and white might help you avoid this pitfall in the future yourself. While the problem with CodePlex’s issue voting lends itself to an easy, superficial fix, it’s just as easy to paint yourself into an corner that isn’t as trivial to escape from.
Similar posts
What do you think? Your comments are welcomed.
I appreciate all of your comments, questions, and other feedback, but please try to stay on topic. If you have a question unrelated to this post, I recommend posting on the ASP.NET forums or Stack Overflow instead.
If you're replying to an existing comment, please use the threading feature. To do this, click the "Reply to this comment" link underneath the comment you're replying to.

Comments
Great post - the UpdatePanel approach is often the result of developers doing anything they can to keep from having to actually write any JavaScript themselves.
Completely agree. This is what happens when MS makes it very easy for developers to create async postbacks, and hides what is really happening in the background.
I mean, when they were building codeplex, I’m sure it worked very fast on their development server on the local network and no one even bothered to ask if it’s necessary to transfer 50KB of data to register a vote.
I have done similar things for ease of development, but only for building an internal app that will run on our intranet for limited use, I would never do such stuff on public facing web sites that would get any decent amount of traffic.
Yes CodePlex is definitly an example of a poor use of UpdatePanels. I’m sure we’re all guilty of it at some point, putting on the UpdatePanels just to make an AJAX-y site without the worry about what the real cost was going to be.
Something your readers my be interested in is a post I did which looks at how to get the most out of UpdatePanel performance to make them a bit less scary - http://www.aaron-powell.com/blog.aspx?id=1195
“I’m not one to complain without offering some constructive criticism though. Especially since we’re talking about a completely free service.”
If only more people have that kind of attitude!
Great job!
Hey everyone, I’m a dev on the CodePlex team and we’re fully aware of these issues. We’re working on moving away from asp.net web forms and moving towards MVC (which means no update panels) in every release, and eventually we’ll get to this page as well. Thanks for the feedback!
This is a great post. It has always amazed me that Microsoft managed to get the .NET framework right, yet I have never seen a website implementation by Microsoft that was even remotely acceptable. Surprisingly, the CodePlex nuances are actually minimal compared to other disasters that I’ve seen (e.g., SharePoint). At least the CodePlex UI is decent (in my opinion). It’s just that the implementation (behind the scene) is poor. Fortunately, I believe that these issues can be resolved.
It’s actually a shame because sites like these give ASP.NET a bad name. Microsoft shouldn’t cut corners on websites like CodePlex because they have the potential to destroy public perception of the ASP.NET platform.
Matt Hawley, I don’t mean for my comment to be taken as criticism to you and your team. I’m sure that have been under the gun to implement a website under the same kind of time constraints that I’ve been faced with. Having said that, I do put emphasis on the management team at Microsoft to allow for the necessary time to see to it that sites like CodePlex, with such high visibility, can be implemented cleanly and efficiently, to demonstrate the real power of ASP.NET. The power that we all know exists, but is often masked by poor implementations [often] due to time constraints.
http://code.google.com and http://github.com/ (also free for open source projects) don’t have these issues. While you’re waiting for CodePlex to be updated you may want to checkout the alternatives… :)
Well, it’s not just the slowness that is the problem. The whole bug tracking feature is weak. Also, integration with Visual Studio (I’m using Team Explorer) is so poor that sometimes I just want to give up. But yeah, the speed is just atrocious: my thinking is that a site should let the user post a bug even if they are using a mobile phone. And not drag 17k worth of data across the network.
@Sean - No hard feelings by any means. We always value our customers input whether positive or negative within CodePlex. As I said, we’re continuing to advance the infrastructure removing these hurdles as much as possible.
@Dmitri - This is our slowest pain point within the CodePlex site itself. We’ll be trying to improve performance in this area in the future. Regarding the integration with Visual Studio, that is out of our control, unfortunately. With the new SVN server support, I recommend giving that client a try as it may prove to be a much better experience. Paired with VisualSVN, it’s a nearly seamless experience.
“We’re working on moving away from asp.net web forms and moving towards MVC ”
And there lies the solution :)
Gotta love - 3 cheers for ASP.NET MVC !
So what exactly is preventing codeplex from running a version of TFS that is both stable and fully-featured like the commercial version?
I guess one could use the updatepanel for smaller pages that do not have lot of traffic. I personally though have never recommended anyone to use them. I prefer to use plain js and pass only the required data to the webservice/pagemethod.
I’ve just recently started spending time in the BlogEngine.Net CodePlex project. Up until last week, just trying to pull up the Issue Tracker (simple GET request) was sooooo painfully slow. It’d easily take more than a minute. I’d go somewhere else while it was pulling up. I even tried re-sorting the Issues once — bad idea! Interestingly, this week it’s been very responsive.
Some of that traffic you pulled for us is frightening to look at :-)
Great post! Excellent way to make your point. Hopefully the CodePlex team doubly get the message, and have started the migration over to MVC.
I think MS should move away from WebForms for consumer sites and focus on MVC, like store.microsoft.com
I find the same issues with the forums.asp.net. Because the site is so damned slow (try replying to a post and wait for the edit form+tabs to load). It discourages me from hanging around and using it.
SO is much better for asking questions these days, because of it’s fluid, succint experience.
i think that the ajax is making developers lazy!
Mojtaba Vali: You mean UpdatePanels make developers lazy, right?
UpdatePanel is a lazy workaround. Stop using it as a shortcut for such short messaging!. Async Postback is still a postback.
Amen :)
I noticed this too and was very frusterated by it. I suggestion I might add would be to simply use the Telerik RadAjaxManager to manage the buttons.
Reasons:
1) They are using Telerik RadEditor so they must already have licenses for it
2) The AjaxManager makes sure that only the items requiring A Sync Postbacks are actually post back, leaving everything else as is.
Just my two bits.
Solid proof that asp.net ajax is a poor solution for ajaxified sites.
i think they did the right thing by supporting jQuery is vs2008….
Great stuff as always Dave! I’ve implemented the same solution on one of my sites. However I would like to know how I could solve the issue of validating that the click came from a logged in user. The site does not currently use the ASP.NET Membership provider. Does anyone have any suggestions? Thanks
Thanks for another great post Dave! It’s always interesting to me how many people really don’t like using UpdatePanels. However, UpdatePanels were a fast and easy way for average UI developers to implement AJAX functionality within our product. At the time, our release cycle didn’t allow much time for looking at other alternatives.
I would say that 95% of our customers don’t notice any performance problems just because the amount of data they receive is not that large, even with viewstate. The other 5% make it clear which pages have issues and we go back and rework those pages using jQuery, PageMethods, WebServices, etc. while attempting to minimize viewstate.
For us, it’s more a matter that our UI developers know their options and make the best decisions for the current circumstances. Not necessarily the best coding approach, but an approach nonetheless. Thanks again.