Real-time data in a browser is cool, unless it becomes "some" time instead of real-time

One of the things AJAX is really good at enabling is real-time, interval based updates of data. Stock quotes, the weather, news headlines, etc... Like Google's Gadgets. All these 'applications' (or gadgets, in the case of Google) are essentially doing is polling a server somewhere based on a timer and retrieving data in real-time for users. Simple, right?


The problem is that if the user is on a WAN or dial-up connection that the time it takes to retreive the data may actually be longer than the specified update interval. Of course, this could also happen in high-volume situations on a LAN, but it's more likely to be an issue on WAN or dial-up connections, or with extremely bandwidth challenged clients like mobile phones and other hand-held devices.

I see this happen on a weekly basis; Don and I game online with friends that are in remote locations, and because they are challenged by congested links that like to drop lots of packets, our "real time" system is sometimes not so "real time", and they often have to reload the page to set things right. I've already tweaked Apache as far as I can to improve performance, and still there are issues depending on traffic conditions out in the great ether that is the Internet.

So I was thinking wouldn't it be cool if I could modify the update interval in an AJAX-application based on the user's connection and perhaps alleviate some of this pain? If they're slow, slow it down. If they're fast, speed it up. And do it dynamically with each request to ensure that as conditions change, the application actually adjusts as well.

Yeah, it would be très cool. But it would be a ton of work for the developer, and probably not worth the effort in the end. After all, I'm the developer in question and I just don't have the time to dig down into the TCP stack from what's supposed to be a simple PHP-based application - if that's even possible.

There is another way, of course, otherwise I wouldn't be writing this entry (mother says it's bad form to point out problems without offering a solution), and as you can probably guess it has something to do with BIG-IP. You got it, you could use an iRule to achieve this functionality.

iRules lets you grab things like TCP round-trip time (rtt), bandwidth approximation, and the estimated number of hops it takes for the client to get to the server. A good discussion of these variables is here in the forums. All these variables affect the response time of data and can be used to determine what the best update interval in a real-time application should be.

All that's required is that you know how the update interval is being set in the Javascript portion of the application, and then replace it using findstr with an appropriate value before the response is sent to the client. 

Voila! A dynamic, adjustable real-time update value that actually takes into consideration the variability of the network in, well, real-time. 

Imbibing: Coffee