Tutorial :Scalable polling of an AppEngine application from numerous “active” clients?


I'm working on an application that will run on Google AppEngine.

I plan to have the web interface of that application wait, among many other things, for notifications coming from the AppEngine server.

Ideally I would have liked to use an XMLHttpRequest() to make a request to the server that would be waiting until the next notification comes from the application.

However there does not appear to be in AppEngine to support this type of logic (correct me if I'm wrong). This means I appear to be limited to polling at periodic intervals.

So the question is:

  • Does anyone have a good suggestion of how to best design this polling mechanism in order to avoid running into CPU usage quotas of AppEngine? Scalability as the number of "active" clients takes off needs to be considered.

I am specifically interested in suggestions for good management of the polling intervals from the client side and tips for efficient handling of the requests in the AppEngine application as the number of "active" clients grows.

PS: the type of information polled from the server will typically be JSON-encoded information about recently updated/added bits of information (read recently as: in the past few seconds or minutes).

Status Update

Here is a summary of my thoughts so far around this question:

  • To minimize the CPU load required to answer each individual request generated by the polling approach: use the memcache to minimize the time it takes to collect the reply information. Need to find pointers to a good example of that.
  • To minimize the number of requests generated to the server by the "active" clients I have several leads:
    • Make the wait between successive polling requests to the server progressively longer if the user is not actively interacting (i.e. not clicking on anything) within the client web page.
    • Piggy back on other types of requests to the server, that is include the results of the polling requests into other request results to save on the number of requests.

Comments and pointers to code examples welcome!



You might be interested in some pubsub implementation. Like the venerable pubsubhubbub, made by guys from Google and Jaiku.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »