Tuesday, September 13th, 2005

Ajax Latency: Myth, Reality, and Solutions

Category: Editorial

Jep Castelein of Backbase has been writing about latency issues, and how Ajax is involved.

Firstly, he talked about Ajax Latency problems: myth or reality?.

In this article he discusses what people are saying and thinking wrt Ajax latency, and adds:

“These days, bandwidth is cheap, latency expensive.”

I can confirm this from my own experience: on www.backbase.com around 80% of the download time is caused by latency, and 20% by download speed (bandwidth). So you can better load some more data beforehand than have very frequent requests for small files.

and points too Async Requests over an Unreliable Network:

  • Avoid Uncaught Exceptions: don’t call the XMLHttpRequest object when it’s still processing another request
  • Implement a solution for timeouts: XMLHttpRequest doesn’t handle this automatically as do other socket client APIs
  • Make it possible to abort a request gracefully
  • Make sure that responses arrive in the right sequence

Jep has just published a new article that discusses Reducing latency with a CDN (Content Distribution Network).

Here he delves into how he measures latency, and the issues that he has seen from watching requests come from around the world to his site running in Amsterdaam.

To Summarize

If you are running a global AJAX website in which you have a lot of static file requests, first try to reduce the number of files, and then consider a ‘traditional’ CDN to further improve performance. Be aware of the ‘security-across-domain’ issue. When we’ve implemented a CDN I can tell you more about the results. If you have good tips for selecting a CDNs, let me know!

Have you run into latency issues wrt Ajax? Any other good solutions?

Posted by Dion Almaer at 11:49 am

3 rating from 5 votes


Comments feed

Multiple xmlHttpRequest objects can also eliminate any conflicts between request, and do not require a custom queue manager. Create a new object when the request needs to be made, and dispose the object when it has done its job. :)

I have a fairly complex interface utilizing xmlHttpRequest on a large scale for almost any control (treeview+xml, menu+xml, ui persistance layer+xml, etc.), and due to this construction the speed is kept acceptably high.

Comment by M. Schopman — September 13, 2005

hi M.Schopman,

Do you run into issues with having too many XHR objects running at once? (e.g. more concurrent requests to the same domain than the browser wants to deal with).



Comment by Dion Almaer — September 13, 2005

One of the DWR unit tests configurations is to run all 200+ tests in parallel. I then load up IE/FF/Op all doing their 200 tests at the same time, at the same time.

I can say that the iframe implementation of Ajax on DWR creaks under IE, but XHR works just fine everywhere. That is so say the server correctly replies to all 600 vaguely concurrent requests without error. To be honest I’m even surprised that Windows can cope.

The lesson is – don’t write your own Ajax code. Use a library like prototype or DWR.


Comment by Joe Walker — September 13, 2005

I agree with Joe about using a library. I’m planning a third article to explain how the Backbase library handles XHR requests, and how you manage synchronous and asynchronous activities (not just limited to loading files).

Comment by Jep Castelein — September 14, 2005

Dion, I haven’t had any issues. There is however a limit in the browser with the amount of connections you can make to a domain. HTTP specifies a maximum of two simultanous connections for a domain. Using multiple subdomains can increase overall speed drastically. The Microsoft Office website scales all visual content on multiple servers, www1.office.com www2.office.com etc. With two sub domains you can have 4 simultanous connections from the browser. With 3 servers, 6 simultanous connections, etc.

You can imagine this can cause really good performance boosts for your applications, but it adds an extra layer of complexity.

Comment by M. Schopman — September 14, 2005

Leave a comment

You must be logged in to post a comment.