*
The moose likes HTML, CSS and JavaScript and the fly likes Ajax application response time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax application response time" Watch "Ajax application response time" New topic
Author

Ajax application response time

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

With lots of trial & error (it has been long time since I did any serious JavaScript) I have finally managed to get my Ajax application similar to google suggest up& running smoothly. However, the response time is rather slow, it takes about 2-3 seconds to display the suggestions list. I have done several things including checks on on timer function instead of onKeyDown of the text-box. Still the response time is not chnaging significantly. Our target is 300-500 ms. The background server side program is a struts action with velocity.

Any ideas, pointers on reducing response time of my Ajax application?

TIA,
- Manish
[ October 04, 2005: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Other than making sure that your Javascript isn't doing anything foolishly time-comsuming, most of the delay will be in contacting the server just like any other server round-trip.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Lane Liles
Greenhorn

Joined: Sep 17, 2005
Posts: 5
I recently worked up a Google Suggest type prototype for a search field in our application and found the bottleneck (in our environment anyway) to be access between the server and the database. I used Microsoft Fiddler (HTTP request header "sniffer") to check overall response times from the client, and also checked access times in my servlet by logging when the request was received, pre/post database calls, and reponse time. Since this was just a demo, I created a quick n' dirty servlet that only handled the AJAX requests, so it was lean and fast, except when it made the DB calls. We're using a third-party, closed source Java/JDBC based engine, so I didn't dig into trying to optimize it.

One suggestion though, which you might have already seen if you've dug into Google's code. In Google Suggest, they aren't sending an XML response back to the client, but just a string that represents a client-side JS method call with parameters. The response data (the suggestions for your textbox) are encoded on the server side as the parameters of the method call that will be executed when it reaches the client. Since there's no XML parsing/translation going on at the client, this should speed things up a bit. My prototype used this method too, so I can't really say what kind of speed increase it buys you. FYI, Gmail uses this same technique (sans the method name, they just send the parameters), and Ruby on Rails skips the XML too by sending back HTML... so do we just call it "AJA" now?

Anyway, hope that helps...
Lane
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

so do we just call it "AJA" now?




That's a good point. I rarely send XML back to the client when using AJAX. I'll either send raw string data that triggers actions on the client, or JSON notation objects that are interpeted on the client.
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

I am producing directly usabel text from my velocity template. I guess i's the strust framework that's causing the delay, in addition we have custom request processor as well. Let me check what a plain servlet can accomplish.

- Manish
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ajax application response time