1

I'm working on the design of a web app which will be using AJAX to communicate with a server on an embedded device. But for one feature, the client will need to get very frequent updates (>10 per second), as close to real time as possible, for an extended period of time. Meanwhile typical AJAX requests will need to be handled from time to time.

Some considerations unique to this project:
This data will be very small, probably no more than a single numeric value.
There will only be 1 client connected to the server at a time, so scaling is not an issue.
The client and server will reside on the same local network, so the connection will be fast and reliable.
The app will be designed for Android devices, so we can take advantage of any platform-specific browser features.
The backend will most likely be implemented in Python using WSGI on Apache or lighttpd, but that is still open for discussion.

I'm looking into Comet techniques including XHL long polling and hidden iframe but I'm pretty new to web development and I don't know what kind of performance we can expect. The server shouldn't have any problem preparing the data, it's just a matter of pushing it out to the client as quickly as possible. Is 10 updates per second an unreasonable expectation for any of the Comet techniques, or even regular AJAX polling? Or is there another method you would suggest?

I realize this is ultimately going to take some prototyping, but if someone can give me a ball-park estimate or better yet specific technologies (client and server side) that would provide the best performance in this case, that would be a great help.

Travis Christian
  • 2,412
  • 2
  • 24
  • 41

3 Answers3

2

You may want to consider WebSockets. That way you wouldn't have to poll, you would receive data directly from your server. I'm not sure what server implementations are available at this point since it's still a pretty new technology, but I found a blog post about a library for WebSockets on Android:

http://anismiles.wordpress.com/2011/02/03/websocket-support-in-android%E2%80%99s-phonegap-apps/

Joel C
  • 5,547
  • 1
  • 21
  • 31
  • 1
    websockets - looks very interestng to me! http://dev.w3.org/html5/websockets/ and http://websocket.org/ – gbjbaanb Apr 15 '11 at 16:36
  • Websockets sounds like what I need, but it seems the browser support is very limited. Is this Phonegap framework required to use Websockets on Android? – Travis Christian Apr 18 '11 at 18:51
  • @Travis No, it's not required, that was just the target platform in that example because Phonegap was being used to develop their application. In fact you shouldn't be limited to using it in a browser, you can make a custom app that supports WebSockets if you wanted. You would just have to implement the W3C WebSocket API yourself: http://dev.w3.org/html5/websockets/ What the browser should do for you is wire up incoming data to JavaScript events using a built-in WebSocket class. Doing it yourself you'd handle the data directly. *Disclaimer: This is theoretical, I haven't tried it yet myself.* – Joel C Apr 18 '11 at 19:49
1

For a Python back end, you might want to look into Twisted. I would also recommend the WebSocket approach, but failing that, and since you seem to be focused on a browser client, I would default to HTTP Streaming rather than polling or long-polls. This jQuery Plugin implements an http streaming Ajax client and claims specifically to support Twisted.

Nicholas
  • 15,916
  • 4
  • 42
  • 66
0

I am not sure if this would be helpful at all but you may want to try Comet style ajax

http://ajaxian.com/archives/comet-a-new-approach-to-ajax-applications

Ryan Matthews
  • 1,043
  • 9
  • 28