Ajax and Flex Data Loading Benchmarks

For close to a year I’ve been working (in my infrequent spare time) on an application that shows differences in data loading for RIAs (Rich Internet Applications), comparing Ajax methods, Ajax frameworks, and various Flex methods. The results are pretty surprising. The screenshot below is from a test run I did with the server running locally. (Note for the screenshot below: All tests except Dojo were 5000 rows, while the Dojo test was 500 rows.)

To run the benchmarks yourself, go to:
http://www.jamesward.org/census/

I have tried to be as fair as possible with these tests. Still, I encourage you to use these results only as an initial guide. You should always do your own benchmarks that more closely resemble your actual use case.

You can find more details explaining the tests and the results inside the “Guide Me” mode of the application, so I won’t go into depth here. Also, the code is Open Source (GPL) on SourceForge. If you feel that a test should be done differently or you find other things that you think should be changed, get the code, fix it, and send me a patch file. Please don’t just tell me I did something wrong. In the spirit of Open Source, help me fix it. I want this application to be as fair and accurate as possible.

While these results may be eye-opening to some, once you understand some fundamental differences between Flex and Ajax, they end up making a lot of sense. Flex applications run within the Mozilla Tamarin VM inside Flash 9. Tamarin does JIT compilation which makes code execution 10 to 1000 times faster than interpreted JavaScript in the browser. Also Tamarin can be very efficient when dealing with typed objects.

In addition, Flex supports a compact binary object serialization protocol, called AMF3, which is extremely fast. There are numerous Open Source implementations using various backend technologies for AMF3, as well as a commercial / supported Adobe product, called Flex Data Services. If you control both sides of the wire in your application, then there is rarely a good reason to serialize and deserialize text. Objects are blazing fast as you can tell by this benchmark. AMF3 is also typically much more efficient across the wire (even without compression) and consumes much less client side memory. JIT compilation and binary object serialization are the primary reasons why Flex AMF3 is so fast, even in the test with the full 20,000 rows. And, it’s not just faster for loading – it also speeds client side sorting and filtering. (Try client-side sorting in the Dojo benchmark and the Flex AMF benchmark.)

A quick note on compression: I did not include compression support in this version because its value really depends on many application-specific factors. For instance, if most of your users have slow connections then compression can help speed things up, but if most have fast connections the added latency can actually make things slower. However, I do want to add a Gzip option to this benchmark for the next release.

This is really a version 0.1 release. There are many improvements I have on the to-do list. And I’d love the community’s help. Here are some things I want to do for the 0.2 release:
– Add Gzip option on tests
– Add a Laszlo test
– Implement more Ajax frameworks that have DataGrids and that support paging and sorting
– Add a server side sorting option
– Add Ajax client side memory usage metrics (don’t know if this is possible)
– Improve the UI for use on projectors (I use this demo in every presentation I give)
– Integrate feedback I get from the initial version
– Maybe add a WPF/E test (which I won’t be able to do because I run Linux)

I sincerely hope that you find this demo useful. I built it as a tool to help people learn more about the various methods of data loading in RIAs. I did not in any way build this to attack Ajax, Dojo, and SOAP. Please help me improve this application so that we all continue to learn more about the technologies available to us.

This entry was posted in Ajax, Flex, Open Source. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Mystic

    Quite interesting :)

    You have in you html file (begining of file) of this blog “9a4″.

  • Mystic

    Sorry.. there is something generating.. Some numbers with every refresh of website… The same in div class=”column1″. Fe. 55f ul.

  • http://www.jamesward.org James Ward

    Very strange. I wonder where those are coming from. Maybe a WordPress plugin? I’ll have to dig in and see if I can figure that one out. Thanks for the heads up.

    -James

  • http://www.numeninternetsolutions.com Don

    Hey James, just wanted to let you know I keep getting an error when trying to view your app in the feed demon window. Works great in IE or Gecko based browsers.

  • http://www.jamesward.org James Ward

    Thanks Don. I’ll look further into that.

  • BillyG

    That error problem is happening all over the web (as seen via my FF anyway).

    ZDNet has been killin me since their redesign.

    Thx for the benchmarks.

  • Bjorn

    Hey James, would love to contribute to version 2.
    Particular to showing results For Flex ZLib compressed XML E4X and how it competes against Flex AM3.

    Bjorn

  • http://www.peopleoverprocess.com Cote’

    Nice stuff! We gotta get some Silverlight in there eventually.

    I can see the XML is slow crowd gettin’ juiced off this for years to come ;)

  • http://www.jamesward.org James Ward

    Hi Bjorn,

    That would be great if you can help add that! Here are the basic instructions…
    1) Get the code from SourceForge http://www.sf.net/projects/flexapps (cvs module is “census”)
    2) Get LCDS from http://labs.adobe.com
    3) Get JBoss 4.0.4
    4) Set the JBOSS_HOME and LCDS_HOME env properties
    5) Copy the default server in JBoss to census
    6) Start JBoss
    7) Run “ant deploy-war” in the dir where you checked out census to

    As far as the UI goes, it would be nice to have an options area on the Navigator with a checkbox for “Enable GZip”. This way GZip could be enabled for any test. For the benchmarks we can just set a request parameter or HTTP header that would get checked in another servlet filter (that does the gzipping).

    Got it? Let me know if you have any questions / problems. james<at>jamesward<dot>org

    Thanks!

    -James

  • Pingback: People Over Process » Blog Archive » links for 2007-05-02

  • Pingback: All in a days work…

  • http://j2eemx.com Bing

    Hi James,

    How are you ?
    Good job, I will analyze and write down it into our magazine, my website as well.
    Maybe next time, you can analyze WPF vs. Apollo ;-)

    -Bing.

  • Pingback: Andre’s Blog » Blog Archive » links for 2007-05-05

  • Nick

    How about a Flex JSON test?

  • http://www.jamesward.org James Ward

    Hi Nick,

    I originally had a Flex JSON test. It is still in cvs if you want to play with it. But I removed it because there were some problems with an early version of the JSON library I was using. I’ll add it back to the list for version 2.

    -James

  • http://blogs.nitobi.com/dave Dave Johnson

    Hey James, this came in useful for a nice Ajax performance screenshot for my JavaOne presentation :)

    I will try to grab the code and look into getting ain XSLT option n there as well since it should be pretty fast in IE but maybe not Firefox.

    -dave

  • Pingback: MadeInFlex » Blog Archive » Comprúebalo tu mismo …

  • Sheng

    Hi, James

    I cannot retrieve the code for testing, from http://www.sf.net/projects/flexapps (cvs module is “census”). It denies the anonymous access (at least empty password does not work). Can you reopen it? Thanks!

    Sheng

  • http://www.jamesward.org James Ward

    Hi Sheng,

    Anonymous CVS is open. Perhaps you can’t access port 2401 on flexapps.cvs.sourceforge.net due to a firewall. That would prevent you from being able to get to the files. Sorry. I will see if there is any way I can migrate everything to SVN.

    -James

  • Arnoud

    Hi James,

    very nince tool!

    I hava a question though…
    The flex dataservices always have a server exec time of 1 or 0 ms. even if i retrieve pages of 1000 records. Is it that fast or is it a bug in your computations?

    Really would like to know because we are probably going to use the dataservives in our project which has high performance requirements.

    Thanks

    Arnoud

  • http://www.jamesward.org James Ward

    Hi Arnoud,

    That must be a bug. Does bandwidth come though? Both values are pushed from the server (or pulled if you can’t make the rtmp connection).

    -James

  • Arnoud

    Hi James

    the bandwidth is always 216 bytes independent of the page size.
    Actually it looks just like your screendump :)

    Arnoud

  • http://www.jamesward.org James Ward

    Arnoud, It sounds like you have found a bug. The bandwidth and server exec time should vary depending on the benchmark and number of rows. Can you let me know what OS, browser, version of Flash, etc you are using? Thanks.

    -James

  • Pingback: links for 2007-05-26 « thebadtiming

  • http://dojotoolkit.org Tom Trenka

    Hi James,

    I’m hearing from Alex Russell that the version of Dojo you’re using for comparison here is 0.4.1, is that right? There was a change made post 0.4.1 that implemented hashtable lookups for the store underlying the Dojo FilteringTable; we were kind of wondering if you’d be willing to pick up the latest version of Dojo and try it? Not that I expect the results to be too different; the reality is that I hit an essentially hard limit at about 450 rows of data before every browser decides it has enough…in this particular case the main issue seems to be rendering in a table element :( Either way, I never designed FilteringTable to be handling anything more than about 200 rows of data (for the aforementioned reason)…

    Thanks!

  • http://www.jamesward.org James Ward

    Hi Tom,

    I’ve updated to 0.4.3 and it’s certainly faster! About twice as fast as far as I can tell. So that’s great! Nice work!

    And just so you know, I really don’t mean to bash on the FilteringTable or Dojo. I think both are great! It’s just that they aren’t well suited for dealing with large data sets on the client. (At least until Tamarin makes it into Firefox.)

    So keep up the great work!

    -James

  • http://dojotoolkit.org Tom Trenka

    Hi James–

    Oh, don’t worry, we know :) Large datasets on the client using HTML tables get very unwieldy very fast…we’re looking at a paging solution in the near future that only renders a small amount of HTML table rows at a time, hopefully that will make a huge difference in performance.

    –Tom

  • http://www.jamesward.org James Ward

    Thanks Tom. Rico does virtual renderers and paging which does greatly improve perceived performance. Let me know when you guys have it working and I’ll add it to the benchmark suite. Thanks again for the heads up and all the hard work on making this stuff better!

    -James

  • Pingback: Benchmarking RIA’s | Barklund.org

  • Pingback: B L O G N A | all things web |

  • Arnoud

    >Arnoud, It sounds like you have found a bug. The bandwidth and server exec time should
    >vary depending on the benchmark and number of rows. Can you let me know what OS, >browser,
    >version of Flash, etc you are using? Thanks.
    >-James

    Hi James,

    A bit delayed but here are the details: flash 9.0.28.0 / windows xp home sp2, / firefox 2.0.0.3

    Arnoud

  • Pingback: sappenin in software » Blog Archive » Flex Web Services are Really Fast

  • Pingback: Emak Mafu Labs Blog » Blog Archive » Flex vs Ajax loading times

  • Pingback: Vixiom Axioms » Flex RubyAMF Screencasts

  • http://blog.iconara.net Theo

    When I run the app the Flex AMF3 test shows up as 90% “transfer time” and just a tiny amout “server exec time” and “render time”, and while it is still faster than any of the other methods it is the slowest when only looking at only transfer time.

    This can’t be right. Since AMF3 data is smaller in size than XML and JSON the time to transfer this between server and client should be the same or less, not more. Moreover, in my experience AMF3 coding is a lot more processing intensive on the server side than XML or JSON generation is.

    How do you measure server exec time vs. transfer time? Could it be that the AMF3 encoding process is registered as transfer time for some reason?

  • http://www.jamesward.org James Ward

    Hi Theo,

    This has bothered me too. What I was told by the engineers is that there is actually some “parsing” or decoding of the AMF taking place before I can get an event raised that the response has returned from the server. However the server exec time should be accurate. I record the server exec time on the server through the servlet filter. When the request first comes into the server I start the clock and when the response is ready to be sent I stop the clock. That should be nearly 100% accurate. But the transfer time could be off if I can’t find out exactly when the response has been fully received by the client. Yet if I can’t get close enough to that event it doesn’t effect the total time measurement. I hope that helps. Feel free to check out the code on sourceforge and see if there is any way you can think of to make everything more accurate.

    -James

  • http://blog.iconara.net Theo

    I wouldn’t be surprised if some of the transfer time is in fact the Flash Player doing some decoding, but doing it before it notifies the Flex application that the data is available. If that time is included in the transfer time I’m not surprised that it looks longer than it should.

    I should have said in the last comment: good work, the cencus application is intuitive and also looks nice. Thanks.

  • http://sethonflex.blogspot.com Seth Caldwell

    I also came to these comments to remark about the processing time of amf not registering, but I see the concern is already here =) There is a way you can measure this, in fact. Do your request with type AMF, that takes time T1 of ‘bandwidth + processing’. Do another request that loads the data as binary using sockets so that flash will not know the binary data is in AMF format and do any parsing on it. It will load this from the server in time T2. T3=T1-T2 is then the time that it took the client to process the AMF data.

  • Pingback: Joeflash’s Enigmacopaedia » Why Flex for RIAs?

  • Pingback: Leonardo França » RIA Benchmarks

  • Pingback: Reading: Silverlight, MIX and More « Tales from a Trading Desk

  • Friedger

    Would it be possible to add a comparison using Curl (www.curl.com)? I am not familiar with Flex but would like to see the results.

  • http://www.jamesward.org James Ward

    Hi Friedger,

    I’m actually working on that with the Curl developers. Should have something in the next few weeks.

    -James

  • Gunny

    I could not find the census app module in sourceforge. All I could see is photographer_db, anvil, and flexpaint. Could you make the census app available for download ?
    Thanks!

  • http://www.jamesward.org James Ward

    Hi Gunny,

    It’s only in CVS.

    -James

  • Pingback: E4X???????AMF???????5??? : blog Boreal Kiss

  • Jordan

    When running the app on your server (http://www.jamesward.org/census/), the clock just keeps spinning, no results ever show. Not sure what’s going on.

    (using ff3.0.1, no firewall restrictions)

    –Jordan

  • http://www.jamesward.org James Ward

    Hi Jordan,

    Sorry for the problems. Unfortunately FF 3 has changed something about how it deals with IFrames. So to run the test you have to click on the results panel. This opens the IFrame and begins the test. I’m working on a new version which will resolve this problem.

    -James

  • Jordan

    Thanks, that worked. Now I’m trying to get the Census app to build and run on my local machine… but I don’t seem to have a flex.war file any where on my system, and after much scouring via Google, I have no idea where that file may be (its a dependency in the build). Is it possible that Flex 3 just doesn’t have it? I don’t see any way to build the Flex sdk into that war file either. I do have the Flex sdk (a few versions) and Flex Builder, but no flex.war file.

    Also, your instructions up near the top need to include installation of a laszlo server (and the env variable).

    Thanks,
    Jordan

  • http://www.jamesward.org James Ward

    Hi Jordan,

    I’m working on a new version that will be much easier to download and run locally. Until that is ready (at least a few weeks) you can try to get things compiling but it’s probably pretty painful. The flex.war file is part of LiveCycle Data Services. The next version will use BlazeDS (which also has a flex.war file).

    -James