Slashdot Mirror


Ajax Performance Analysis

IBM Developerworks' latest was submitted to us by an anonymous reader who writes "Using Firebug and YSlow, you can thoroughly analyze your Web applications to make educated changes to improve performance. This article reviews the latest tools and techniques for managing the performance of Ajax applications along the life cycle of your application, from inception through production."

36 comments

  1. Yahoo's Problems Are Not Your Problems by davecb · · Score: 2, Informative

    A good review and counter-argument is available at the "codinghorror" blog where Jeff Atwood points out the codinghorror blogYahoo's Problems Are Not Your Problems

    --dave

    --
    davecb@spamcop.net
    1. Re:Yahoo's Problems Are Not Your Problems by davecb · · Score: 1
      --
      davecb@spamcop.net
    2. Re:Yahoo's Problems Are Not Your Problems by Bogtha · · Score: 3, Informative

      Hmm, I'm not so sure about some of that. For instance:

      Yahoo recommends turning ETags off because they cause problems on server farms due to the way they are generated with machine-specific markers. So unless you run a server farm, you should ignore this guidance. It'll only make your site perform worse because the client will have a more difficult time determining if its cache is stale or fresh. It is possible for the client to use the existing last-modified date fields to determine whether the cache is stale, but last-modified is a weak validator, whereas Entity Tag (ETag) is a strong validator. Why trade strength for weakness?

      Because "strength" isn't anything particularly important here. The difference between strong and weak validators is that a strong validator is supposed to change even if only minor alterations take place (e.g. spelling mistakes), while a weak validator can remain the same if minor changes take place.

      In practice, I've never seen anybody make a distinction like this for websites/web applications. If anybody did bother, then weak validators would be more efficient, as they would have a better cache hit ratio. For all intents and purposes, there is no difference between a strong and a weak validator. But what you are doing is computing and transmitting useless ETag headers with every single request you serve, so it is beneficial to turn them off, even if you don't have a server farm. Last-Modified is good enough for practically everybody. If Last-Modified isn't good enough for your purposes, then you don't need to be told to switch ETags back on, you know what you are doing.

      All you're really saving here is the cost of the client pinging the server for a new version and getting a 304 not modified header back in the common case that the resource hasn't changed. That's not much overhead.. unless you're Yahoo.

      Well how much overhead it is really depends on what it is you are doing. If it's expensive to figure out if the resource has changed, you don't want to incur that expense a lot, for example naïve dynamic stylesheet implementations can noticeably slow down a site. And remember, even if you have a fast server, it doesn't mean your users have a fast connection, and going back and asking the server if things have changed for a dozen resources on the page when you know for a fact you don't change them for months at a time is ridiculous.

      His basic point, that you shouldn't take Yahoo's advice as gospel is good, but you shouldn't automatically assume that efficiency is only something that benefits giants.

      --
      Bogtha Bogtha Bogtha
    3. Re:Yahoo's Problems Are Not Your Problems by Anonymous Coward · · Score: 0

      You can't really critique either Yahoo or Atwood. The only way to optimize the site is for the developer to understand HTTP and web application performance. YSlow and that article are for the majority of web site operators who are clueless about such things; the kind of folk who gzip static content on each request instead of serving a pre-compressed file. The kind of folks who send a 20K HTML message or 1MB word document in place of a < 1k plain text email. The kind of folk who even when you point out the stupidity of what they're doing respond with "well I think that...".

    4. Re:Yahoo's Problems Are Not Your Problems by DavidTC · · Score: 1

      You're right about ETags. ETags are useful when you have cached, dynamically-generated content, and can't use Last-Modified. Well, you could use it, but handling faking that is more complicated than just running the end result through crc32().

      Anything else and ETags are just just dumb. OTOH, they're not actually slowing anything down for the end user.

      OTOH, YSlow's still stupid here, because it makes some crazy comment about server farms. Look, Yahoo, I don't know who you think is using this software, but 99.999% of the people using this outside of you guys do not have 'server farms'. Tell people to turn it off unless they need it, not if they're using a server farm.

      And the same with CDNs. Really? They think normal websites should be using CDNs? Are they on drugs? And CDNs help very little with the actual 'speeding things up for the end user' when talking about images and stuff (As opposed to videos.), which is why people are using this software: They wish for websites they are in charge of to load faster for the end user. That's it, that's all. They want it to open in 8 seconds on dialup, not 22.

      And those two things are rated 10 and 11, so people might actually think they're important, and spend time on the, only to discover those have nothing to do with the apparent speed of their website.

      To speed things up, there are only two non-content pieces of advice in YSlow that are useful: Use gzip, and use an Expires header. (For repeated images especially.)

      Plus the 'use less images/scripts', 'put scripts at the end', and 'minimize JS' are useful content advice. (Someone should write an apache module that runs JS through a code minimizer.)

      --
      If corporations are people, aren't stockholders guilty of slavery?
    5. Re:Yahoo's Problems Are Not Your Problems by Anonymous Coward · · Score: 0

      This thread is far too informative for Slashdot. Take your knowledgeable and polite discussion somewhere else!

    6. Re:Yahoo's Problems Are Not Your Problems by Rob+Kaper · · Score: 1

      Look, Yahoo, I don't know who you think is using this software, but 99.999% of the people using this outside of you guys do not have 'server farms'.


      Actually, 99.999% of websites probably do not run on a dedicated server but on a shared host - most of them using some sort of cluster solution. Which is precisely why ETags won't work unless you turn off the server defaults so you can generate your own using server-independent data.

      They think normal websites should be using CDNs? Are they on drugs?


      Stop dissing Yahoo. They wrote their guide for high-performance web sites, not normal web sites.

      And a CDN actually is a very good idea. Using one (even if you start by just using a virtual host or S3 for static data) separates application logic from content. That's never a bad thing - it makes it a whole lot easier to optimise dynamic and static content differently regardless of whether you are using Yahoo's suggestions or others.
  2. A capacity planner's niggle by davecb · · Score: 3, Interesting

    It's actually useful to break the response time out into three parts:

    1. 1) Round-trip time, the latency from the network

      2) Transfer time, the time from receiving the first byte of the page to the time the last byte arrives. This varies greatly with page size, and is the time you use to do KB/S calculations as well.

    2. 3) Latency proper, the time between sending the request and receiving the first byte of the page. This is the time that grows during an overload, and the one that capacity planners use to do queuing models to see how much the server will slow down by under an overload.

    --dave (a capcity planner) c-b

    --
    davecb@spamcop.net
  3. Performance is key by Anonymous Coward · · Score: 0

    An only C++ can deliver on this.
    I am with Bjarne on this one.
    Bjarne Stroustrup, creator of the C++ programming language, claims that C++ is experiencing a revival and
    that there is a backlash against newer programming languages such as Java and C#. "C++ is bigger than ever.
    There are more than three million C++ programmers. Everywhere I look there has been an uprising
    - more and more projects are using C++. A lot of teaching was going to Java, but more are teaching C++ again.
    There has been a backlash.", said Stroustrup.

    He continues.. ..What would the world be like without Google?... Only C++ can allow you to create applications as powerful as MapReduce which allows them to create fast searches.

    I totally agree. If Java ( or Pyhton etc. for that matter ) were fast enough why did Google choose C++ to build their insanely fast search engine. MapReduce rocks.. No Java solution can even come close.
    I rest my case.

    1. Re:Performance is key by Anonymous Coward · · Score: 0

      Go back to trolling Reddit, qwe1234.

    2. Re:Performance is key by ZwJGR · · Score: 1

      From what I've seen of the transport tycoon deluxe code dumps, it was written entirely in not particularly efficient assembly...
      (I am a TTDPatch developer)

      Writting code in assembly does not equal significant speed or efficiency increase unless you *really* know what you are doing, and are prepared to put a lot of effort into very implementation/processor specific/obscure optimisations (it probably does mean a reduction in code size though, but hardly anyone cares about that these days :( )

      Just using a better algorithm and not using bloat libraries or redundant/overdone code will generally improve efficiency more than writing anything in assembly (assuming you write it in C or something along those lines and not a bloat/GC/excessively-OOP language)
      Plus assembly is very nonportable, which is generally frowned upon these days for many projects.

      --
      There is no psychiatrist in the world like a puppy licking your face - Ben Williams
    3. Re:Performance is key by Anonymous Coward · · Score: 0

      Splendid sig!

    4. Re:Performance is key by achacha · · Score: 1

      I do agree that C++ is going to get a big resurgence as people are going to start looking for faster ways to execute their applications (and AJAX calls) and while scripting is adequate for low volume, once the volume of users goes up you really want the server to be the least of their concerns and concentrate on speeding up the network, database, etc.

      AJAX makes a lot of little calls back to the server and it is critical that they are processed very quickly to give the site a responsive appearance, there is an appreciable difference between an ajax server response of 10ms compared to 50ms (after you factor in the network latency, bandwidth, jitter and other network issues).

      I'm hoping C++ comes back faster, I am disliking java more and more every day. I hate the long build times, long deploy to tomcat times and long startup times; I waste more time now waiting to verify/debug/enhance than I ever did with C++. My browsing and slashdot posting skills did go up since I do more of it now while I wait.

  4. innerHTML??? by XanC · · Score: 1

    The author appears to endorse the use of innerHTML as opposed to DOM manipulation.

    I suppose it has its place in a performance analysis, but mention might be made that it's just not worth the trading off standards compliance and futureproofing. When I see innerHTML being manipulated I assume the designer didn't know what he was doing.

    1. Re:innerHTML??? by Anonymous Coward · · Score: 0

      I agree with XanC on this one. innerHTML, and document.write are a strong indicator of cluelessness. It's a safe bet their site will have SQL injection and XSS problems as well.

    2. Re:innerHTML??? by POWRSURG · · Score: 1

      The purpose of the article was improving performance and response times. This means trading in practices which one should be doing to optimize for what works best. While DOM manipulation may be the standards compliance way of going it is dramatically slower than innerHTML. It is only recently that Safari and Opera have been able to increase the speed of DOM manipulation, but sadly IE and Firefox (the two more used browsers) show better results for innerHTML. In my own testing Firefox 3 was closer to the Opera timing, only with the innerHTML and DOM method results reversed.

      And future proofing isn't really an argument because the prevalence of innerHTML is so vast that dropping support for such a feature is equivalent to market share suicide. It would break so many sites that it would kill any base said browser had.

      DOM manipulation is a useful tool, but one needs to know when to use it and when not to. I typically start with DOM manipulation when writing a JavaScript application using createElement for new nodes. If new nodes need to be created within a loop, I first create one node outside of the loop, and then clone a newer second node for each iteration (as mentioned in my first link). It is only after that that if performance is lacking AND I am lucky enough that I did not need to append any event handlers to said elements that I resort to innerHTML.

  5. Client-side execution by truthsearch · · Score: 3, Insightful

    I recently did a performance analysis of a complex site I've worked on for over a year. My primary tool was Firebug. While the size of the HTML + CSS + JS per page is pretty large, it turns out compressing them and setting header cache only saw a small performance improvement. The execution of JS like Scriptaculous actually accounts for more than 50% of the time it takes to render the pages. Since we only use Scriptaculous for drag-and-drop we're considering alternatives, like mootools or custom code. Loading as much JS as possible from the bottom of the page instead of the head can help, but isn't always an option. Focusing on CSS and JS performance has now made a huge improvement in perceived site performance.

    During the initial development we never considered that simply loading one JS library (even when it's not used for inserting HTML) could slow down page rendering that much. On JS or CSS heavy sites, client-side loading, rendering, and runtime execution can easily account for 50% to 90% of the time it takes to see a final page. So while I've usually focused entirely on server side performance, I now know to pay more attention to the speed of client side rendering. Lesson learned.

  6. Firebug essential; YSlow useless by hobo+sapiens · · Score: 2, Informative

    I use AJAX all the time. Firebug is an essential tool for me. It is probably one of my most important web dev tools. You can see all server requests. Even if you don't do AJAX, that is useful. Also, the inspect option on Firebug allows you to make CSS changes without committing to the server. Without Firebug, I'd never be able to have the same insight into my pages.

    YSlow is worthless for me. Where I work, I do web development on the intranet. I do not configure the servers, and don't really even have the ability to do so. On the other end, any stuff I might do on the internet will most likely be hosted by some hosting company. Many of the things that YSlow flags are server config items, not *code* items. Sure, that has its place, but if you are a web developer (not a SA) then YSlow gives you a bunch of useless info, then a low grade if your servers are configured a certain way. Ironically, it comes from Yahoo, the masters of the bloated web page. Come to think of it, I should probably get around to uninstalling it instead of just leaving it disabled.

    --
    blah blah blah
    1. Re:Firebug essential; YSlow useless by Anonymous Coward · · Score: 0

      I agree that Firebug is essential, I didn't realize how much I miss it until I made the switch from windows to XUbunty 8.04 that comes with Firefox 3b5 as the default browser. Fire bug has not caught up with this release yet and it's painful.

  7. There's a place for innerHTML. by mosel-saar-ruwer · · Score: 1


    <html>

    <body>
    </body>

    <script language="javascript">
    theDiv = document.createElement("DIV");

    theFont = document.createElement("FONT");
    theFont.style.fontFamily = "verdana";
    theFont.style.fontSize = "24";
    theFont.style.fontWeight = "700";

    theFont.innerHTML = "Hello World!"

    theDiv.appendChild(theFont);
    document.body.appendChild(theDiv);
    </script>

    </html>

    1. Re:There's a place for innerHTML. by larry+bagina · · Score: 3, Informative

      theFont.appendChild(document.createTextNode('Hello World'));

      If it is supposed to be text, createTextNode will properly handle &, <, etc, whereas innerHTML won't.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    2. Re:There's a place for innerHTML. by AngryLlama · · Score: 0

      True. And he shouldn't be using a FONT tag either..

  8. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  9. NoScript by slashgrim · · Score: 3, Insightful

    All websites should have an option to run without fancy Javascript (and still be fully functional!). It makes no sense that a web site should bog down my 400Mhz PDA.

    1. Re:NoScript by ale_ryu · · Score: 1

      I'll second that. And add a no flash option also. God I hate it, mostly because flash designers want to use it on everything.

    2. Re:NoScript by Anonymous Coward · · Score: 1, Interesting

      I concur. This is all the more reason to use unobtrusive JavaScript. Same great functionality with more compatibility. I just wish more sights would learn how this works.

  10. Perhaps CmdrTaco ought to read this article by Anonymous Coward · · Score: 0

    Seriously. Trying to retrieve comments beyond the first 25 takes freaking forever, and FireFox is completely hung during the wait. I miss the old comments system.

    1. Re:Perhaps CmdrTaco ought to read this article by davecb · · Score: 1

      Odd: my 750 MHz box flies on the new system, using a pretty old Mozilla, version 1.7

      --dave

      --
      davecb@spamcop.net
  11. thanks! by rootpassbird · · Score: 1

    Being well aware of the thankless, unforgiving nature of the open web, thanks for the link to the article :-)

    --
    Hackers have long memories. It works both ways.
  12. Depends ... by ScrewMaster · · Score: 2, Funny

    Ajax Performance Analysis

    All I know is, my floors have a nice shine.

    --
    The higher the technology, the sharper that two-edged sword.
    1. Re:Depends ... by smittyoneeach · · Score: 1

      It's a dessert topping!

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  13. Yea everyone uses C++ for ajax!!!! by Anonymous Coward · · Score: 0

    dumbass

  14. Ajax, JS and sites like Digg.com by thejynxed · · Score: 2, Informative

    Talk about making your browser crawl like a turtle, the scripts on that site time out constantly. It's even worse than Yahoo, because at least on Yahoo, the scripts never time out. I have the same issue with Reddit and other such sites. Not everyone has 10+ mbit connections running on Quad-Core machines with 4 GB of RAM. Web devs seem to forget this more than any other programmer class. Just because it runs fine on your 100+ mbit connection and Intel Mac at work, doesn't mean it runs that way anywhere else.

    Funny thing: If I totally disable JS, then the sites load up REALLY fast, I just can't do anything like reply to comments :)

    --
    @Mindless Drivel: 100% of Twitter posts ever Tweeted.
  15. Take Firebug with a grain of salt by TLLOTS · · Score: 3, Interesting

    While I love Firebug and use it daily for web development, you shouldn't trust its net tab too much. I've found in numerous instances it has grossly understated load times, for example loading a very PHP heavy page which Firebug claimed was loading in 13ms, however serverside performance testing showed that the load time was actually over 1 second. I've actually found Safari's new Web Inspector tools to be much more accurate in this regard so I'd recommend using them for performance testing if you suspect Firebug isn't telling you everything.

  16. JSON v XML, XSLT vs dom rendering by EatAtJoes · · Score: 1

    I'm a bit of a noob to AJAX, but/and getting good performance on data-heavy AJAX pages has been a real challenge. I'm specifically working on a data grid with 1000+ rows using Ext. I've gotten it to be acceptable via techniques like behind-scenes paging, direct innerHTML modification instead of relying on library grid redraws, etc etc. I haven't tried simply rendering the grid with XML->XSLT, though (the grid widget is awful nice ...)

    It's probably unrealistic to want a web page to present a christmas-tree grid with this much data but a guy can dream can't he?

    I've also noticed that JSON eval() calls are tremendously CPU intensive in IE (as opposed to FF) -- perhaps IE likes XML better? (Didn't innerHTML come from M$ in the first place?)

    1. Re:JSON v XML, XSLT vs dom rendering by achacha · · Score: 1

      I feel your pain, we are using ext and while it's a wonderful toolkit the json stuff is quite time consuming on both server and client, time that can be spent doing something more useful like rendering the actual content. In some places I've resorted to sending actual HTML snippets and using innerHTML to "insert" them directly without relying on ext/json. For non-performance critical tasks it's a pretty nice library.