title: Scalable polling of an AppEngine application from numerous "active" clients?
body: <p>I'm working on an application that will run on Google AppEngine.</p>
  
  <p>I plan to have the web interface of that application wait, among many other things, for notifications coming from the AppEngine server.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>So the question is:</p>
  
  <ul>
  <li>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.</li>
  </ul>
  
  <p>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.</p>
  
  <p><em>PS</em>: 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).</p>
  
  <p><strong>Status Update</strong></p>
  
  <p>Here is a summary of my thoughts so far around this question:</p>
  
  <ul>
  <li>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. <strong>Need to find pointers to a good example of that</strong>.</li>
  <li>To minimize the number of requests generated to the server by the "active" clients I have several leads:
  
  <ul>
  <li>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.</li>
  <li>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.</li>
  </ul></li>
  </ul>
  
  <p>Comments and pointers to code examples welcome!</p>