Any ideas, pointers on reducing response time of my Ajax application?
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?
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.
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.
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad: