Friday 27 November 2009

Testing the real time web.

I've made some more changes to my PubSubHubBub (quite a mouthful so I use PuSH instead) subscriber in Scala. I've decided to implement a REST admin interface to allow me to list, add or remove subscriptions. I quite like the idea of having a REST API, as it allows me to interact with the subscriber with a simple command line tool such as curl. And if I have time, I could build a nice looking Web UI (maybe GWT) with JavaScript invoking the REST API underneath.

A nice way of testing that PubSubHubBub really works (and how fast it is) is to subscribe to Google Reader Shared Items feed. Google Reader exposes your shared items as a PuSH enabled Atom feed. See this blog post for more details. I use my shared list for testing, and it is available at: http://www.google.com/reader/public/atom/user%2F05268996354213702508%2Fstate%2Fcom.google%2Fbroadcast

Every time you share an item via Google Reader, it sends a notification to the Hub, and the Hub in turn notifies the subscribers. And in my experience, this tends to happen very fast, in few milliseconds.

Although PubSubHubBub brings the promise of the real time Web closer to reality it is a shift from the way feeds are consumed. In vanilla Atom or RSS, all a client has to do is to poll feeds at regular intervals. This may not be very efficient, but it is quite simple to implement and only requires that the client has access to the Web. PuSH is a lot different in the sense that the client that consumes feeds is now a server (more precisely a Web Service) which is accessible from the rest of the Internet. This is a bit more difficult to implement, and has some other serious implications which I have not addressed in my exercise, such as authentication and authorization.

2 comments:

  1. This is interesting stuff Guillaume. It could become the backbone to real-time event-driven web applications. A great project to show the strengths of Scala too.

    ReplyDelete
  2. Cheers Alan.

    PuSH is very useful for the backbone (servers talking to each other) but you still have to rely on Comet hacks to reach the browser. I have been thinking of using Lift to implement a UI frontend on top of my PuSH service as Lift is pretty good at writing Comet apps. The other interesting development on the real time web front is the incoming web browser support for HTML5 WebSockets (already available in Chrome already) which allows bi-directional sockets, making two way communication a lot easier. Scala can play a role there as well, especially when using the Actor model to abstract the way clients communicate with servers.

    ReplyDelete