views:

108

answers:

3

I'm creating a web application on Google AppEngine where I want the user to be notified a quickly as possible after certain events occour. The problem is similar to say a chat server in that I need something happening on one connection (someone is writing a message in a chat room) to propagate to a number of other connections (other people in that chat room gets the message). To get speedy updates from the server to the client I'm planning on using long polling with XmlHttpRequest, hoping that AppEngine won't interfere other than possibly restriing the timeout. The real problem however is efficient notification between connections on AppEngine.

Is there any support for this type of cross connection notification on AppEngine that does not involve busy-waiting? The only tools I can think of to do this at all is either using the data storage (slow) or memcache (unreliable), and none of them would let me avoid busy-waiting.

Note: I know about XMPP support on AppEngine. It's related, but I want a browser based solution, sending messages to the users by XMPP is not an option.

+1  A: 

The App Engine roadmap has Comet support, otherwise you will have some difficulty achieving this.

Jason Hall
Can you elaborate on exactly makes it impossible to do long polling on AppEngine today, and what is meant by "comet support" for AppEngine?
Freed
+3  A: 

Requests on App Engine are limited to 30 seconds execution time, which makes long polling difficult. Further, you need to keep your average execution time low, or you will very quickly run out of instances to execute your queries - App Engine will only provision new instances if your app is reasonably fast. For those reasons, Long Polling is extremely strongly discouraged on App Engine.

If you're prepared to wait a while, however, the roadmap includes "Support for Browser Push (Comet) communication", which is exactly what you're looking for.

Nick Johnson
Thanks you, that explains what the limitations are that will make it difficult to do long polling in practice.
Freed
There is a quota on, and thus costs associated with, both HTTP connections and datastore API requests, and you'll end up burning through both really quickly if you use long-polling in practice.
Jason Hall
A: 

You could always use a hosted comet service, such as WebSync On-Demand. That'll let you push events out regardless of what type of server you use for the hosting.

jvenema