Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Programming Technology

AJAX Applications vs Server Load? 95

Squink asks: "I've got the fun job of having to recode a medium sized (500-1000 users) community site from the ground up. For this project, gratuitous use of XMLHttpRequest appears to be in order. However - with the all of the hyperbole surrounding AJAX, I've not been able to find any useful information regarding server load [Apache + MySQL] when using some of the more useful AJAX applications, such as autocomplete. Is this really a non-issue, or are people neglecting to discuss this for fear of popping the Web2.0 bubble?"
This discussion has been archived. No new comments can be posted.

AJAX Applications vs Server Load?

Comments Filter:
  • Depends (Score:5, Insightful)

    by Bogtha ( 906264 ) on Monday December 05, 2005 @08:10PM (#14189800)

    There isn't any useful information out there because it all depends on what you are doing.

    Take a typical web application for filling in forms. One part of the form requires you to pick from a list of things, but the list depends on something you entered elsewhere in the form. In this instance, you might put the choice on a subsequent page. That's one extra page load, and needless complication for the end user. Or, you can save the form state, let them pick from the list, and bring them back to the form. That's two extra page views and saving state. Or, you can use AJAX, and populate the list dynamically once the necessary information has been filled in. That's no extra page views, but a (usually smaller) JSON or XML load.

    In this instance, using AJAX will usually reduce server load. On the other hand, something like Google Suggest will probably increase page load. Without knowing your application and its common use patterns, it's impossible to say. Even using the exact same feature in two different applications can vary - autocomplete can reduce server load when it reduces the overall number of searches, but that's dependent upon the types of searches people are doing, how often they make mistakes, how usual it is for people to search for the same thing, and so on.

  • could be less load (Score:3, Insightful)

    by josepha48 ( 13953 ) on Monday December 05, 2005 @10:23PM (#14190581) Journal
    you could experience less of a load as you will not be reserving up the entire page each time you "refresh".

    An example is an application that display a list of cities in a state, after a user selects the state. (1) If you send ALL the data to the client at onece, its a large file transfer and takes a long time. This produces a heavy load all at once. (2) If you coded it to refresh the whole page after the selection then it is a smaller initial load, but on the 'refresh' you are sending the whole page plus the new data. (3) If you use AJAX, you only have to send the initial small request ( not the heavy load ) and then the second request for the part of the page that needs updating.

    Between 2 & 3, #3 is better because it reduces the second hit on the server and network as it does not have to resend parts of the page that have already been sent. Between 1 and 3 you actually will have more hits on the server but #3 will result in less data being sent across the network.

    The biggest problem with #2 is that sometimes refreshing a whole page ( onchange ) confuses users. Yes, this may sound weird, but I have had people tell me this.

    The biggest problem with #3 is that if the server request fails, you must code for this and if you don't the user may not know what happened. Also how do you handle a retry on something like this?

  • Re:Really... (Score:2, Insightful)

    by houseofzeus ( 836938 ) on Tuesday December 06, 2005 @02:26AM (#14191525) Homepage

    For every website/application you can name that was made fantastic by the use of AJAX it is possible to list at least ten that didn't need it and only have it to try cash in on the latest fad.

    The GP's point was a valid one, it is important that people sit down and work out whether AJAX will actually benefit their application.

    Despite all the crap being spouted about AJAX it is NOT some magic wand that works for every given situation.

  • by jgardn ( 539054 ) <jgardn@alumni.washington.edu> on Tuesday December 06, 2005 @03:45AM (#14191822) Homepage Journal
    You're going to want to separate out your web server if you are going to face any real load. A good mod_perl implementation with a PostgreSQL (or even MySQL) can give you the kind of dynamic speeds you need. Since the AJAX queries usually translate to a single call, you can probably get much more performance than the older style where each page had to make several queries.

    To serve up the webpage, I think you should go with a static HTTP server if you can. If you can't I would use a different server because there are different queries and a different load characteristic. For starters, people can wait 2 seconds while a new page loads, but they will get antsy if they have to wait more than 1/2 a second for a trivial AJAX query to complete.
  • by Nurgled ( 63197 ) on Tuesday December 06, 2005 @08:53AM (#14192657)

    This isn't directly related to your question, but it's something that most people experimenting with "AJAX" seem to be overlooking. It's too easy to fall into the trap of using XMLHttpRequest to do everything just because you can, but by doing that you are restricting yourself to a small set of browsers that actually support this stuff. This doesn't include many of these phone/PDA browsers that are becoming more common.

    Also worth noting is that changing the DOM can cause confusion to users of aural browsers or screen readers. In some cases this doesn't cause a major problem; for example, if you have a form page where choosing your country then changes the content of the "select region" box that follows, the user will probably be progressing through the form in a logical order anyway and so the change, just as in a visual browser, won't be noticable. However, having a comment form which submits the comment using XMLHttpRequest and then plonks the some stuff into the DOM will probably not translate too well to non-visual rendering, as the user would have to backtrack to "see" the change.

    Of course, depending on the application this may not matter. Google Maps doesn't need to worry about non-visual browsers because maps are inherently visual. (though that doesn't actually use AJAX anyway!) Google Maps would be useful on a PDA, however. I'm not saying "avoid AJAX at all costs!" but please do bear in mind these issues when deciding where best to employ it. Most of the time it really isn't necessary.

  • by Pascarello ( 909061 ) on Tuesday December 06, 2005 @10:32AM (#14193125)

    There are a lot of good points posted in here. Caching on the client on the server are two big things for a good application that is using the XHR. A good database design is also key if you do not want to use "like" which slows down the search. In Ajax In Action [manning.com] as discussed on Slashdot here [slashdot.org]. In chapter 10, the project talks about how to limit post backs with an auto suggest by using the clientside efficiently. The basic idea examines the results returned. If it is under a certain number, it uses JavaScript regular expressions to trim down the dataset instead of hitting the server. Plus there is a limit on number of results returned so it speeds up response time.

    One thing I can not get through people's minds enough when I do my talks is Ajax is not going to be a "client-based app" on the web. The main reason is going to be network traffic getting in the way of your request. Imagine a dial up user in India with your server sitting in the United States. The request is going to have to travel to the other side of the world and back with the slow speeds of dial-up. Testing on your localhost is going to look great until you get on an outdated shared server hosting multiple applications with a full network load. Yes we are talking small requests pinging the server, but 1000 users with a 10 letter word could mean death if you designed the system badly!

    I love XHR, cough Ajax, but you need to look at what you are dealing with. The design of an XHR app can kill you if you do not think it out fully.

    My 2 cents,
    Eric Pascarello
    Coauthor of: Ajax In Action

  • by Anonymous Coward on Tuesday December 06, 2005 @11:26AM (#14193492)
    I am not quite sure what the question is, but I am fairly confident that AJAX is not the answer. IMO AJAX is a freak of nat..., computer science.
    AJAX reliance on ECMA-script seems like a shaky foundation at best. I imagine debugging ECMA-script can be quite clunky and even if tool support might solve this problem at some point, there is no guarantie that browsers will interpret ECMA-script the same way, it seems like an embrace and extend waiting to happen.
    I will not venture too far into the dynamically vs. statically typed language discussion other than stating that personally I prefer strongly typed languages.
    I get the impression AJAX is a quick-and-dirty solution to a problem that requires something more advanced.
    It seems like AJAX is an attempt to overcome the shortcomings of thin clients using the technology that had the widest market penetration, without considdering whether the technology was the appropriate tool for the job.
    I am afraid that we will have to live with AJAX for a long time. A tradgedy similar to VHS victory over betamax, where an inferior technology beat a superior one.
    I wonder if something like a next generation X-Server browser plugin or a thick client Java framework might not have been better suited for the job. It can't help but feel like AJAX is somehow trying to force a round peg through a square hole.
  • Re:Really... (Score:5, Insightful)

    by kingkade ( 584184 ) on Tuesday December 06, 2005 @07:04PM (#14197991)
    I think we're all saying the same thing here, try to see if AJAX (ugh i feel dirty) makes sense in your webapp. Hard to see sometimes (see below)

    Of the three examples Google maps is the only one that uses AJAX in a manner that provides major benefits over a traditional implementation

    Now hold on. Gmail is another perfect example of how AJAX can help. Say I have an inbox with 50 emails and I want to trash, archive, or otherwise do something to one message/thread that would involve it being removed from my view, the rest of the inbox (not to mention all the other peripheral UI elements) shouldn't change. In the old way we'd re-request all this tremendous information (say ~95% of the UI) that didn't even change! And this is even more obvious when you remember that each seemingly tiny, simple piece of the UI (say a message line) may use a bunch of HTML (not to mention scripts, css, etc) behind the scenes to make it look/feel a certain way. In the AJAX version we'd just have to add some scripting to remove that DOM element from the page and send a simple, say 0.5KB, HTTP message like "[...]deleteMsg.do?msgid=x[...]" to the server. You still have to suffer the TCP round trip latency (but less so), but the difference can be dramatic, no?
  • Re:Really... (Score:3, Insightful)

    by petard ( 117521 ) * on Wednesday December 07, 2005 @12:30AM (#14199652) Homepage
    Not really. Of the three examples Google maps is the only one that uses AJAX in a manner that provides major benefits over a traditional implementation.


    Have you used gmail? Have you used any other web mail applications? I've used gmail, hotmail (the old, pre-ajax one), yahoo mail (the old, pre-ajax one), hushmail, squirrel mail, open webmail and outlook web access all fairly heavily at one time or another. gmail and OWA really stand out from that crowd. gmail uses AJAX, and OWA is conceptually very similar.

    I haven't used digg enough to comment.

    Your point (that developers need to ask themselves whether technology X provides any real benefit to their application) is sound, but I haven't noticed applications where, as you claim, AJAX detracts from the experience compared to other techniques. Could you point to a few examples where the AJAX implementation of an app sucks compared to the non-AJAX implementation?

"If it ain't broke, don't fix it." - Bert Lantz

Working...