iBrasten

My methods of calculating time are far superior to yours, in every way.

 

This is the blog of Brasten Sager, a freelance software developer, Mariners fan, guitarist, haphazard philosopher.

An infinite number of monkeys...

October 26, 2005 @ 02:57 AM

In August I wrote a little blurb about a way of making your AJAX apps responsive while reducing the frequency with which your clients ping your server.  It came out like so:

"Instead of pinging the server every second – which works but can suck server resources – why not allow the client to “listen” for incoming messages? This can be accomplished pretty easily, it turns out. Instead of pinging for data then closing the request, simply have the server hold the connection open if there isn’t any data to send. As soon as data is available, send it down the wire and terminate the connection. The client simply has to respond to two possible results: The connection returned data, or the connection timed out. Both results require immediately opening another connection to the server and starting the process over again.  Very easy, actually."

Not everyone liked my idea, but today I found someone who posted the same idea on their website about the same time.  Greg Kimberly wrote:

"Ideally, what I wanted to do was to have the clients poll at much more infrequent intervals, say every 30 seconds, and still get one second or less message send/receive latency. A solution came from an unlikely place – the unreliable nature of the Internet. Due to the unpredictable nature of Internet connections, the XMLHTTP function I intended to use to call the server from the browser had a long timeout – over 30 seconds. That long timeout could be used to turn around the control of each call – letting the server keep a poll call open for half a minute and return any data that arrived during that time immediately."


Greg goes on to provide sample code for both client and server pieces.  He also had actually IMPLEMENTED the idea (which can be tested at his website), whereas I was just speaking hypothetically.  So kudos to Greg Kimberly.

    Relevant Links
    Greg Kimberly on AJAX Polling – http://notes.gak.com/polling/
    My post on AJAX Polling – http://brastensager.com/blog/?p=210

0 Responses to “An infinite number of monkeys...”