Bayeux and CometD: Open Source Comet Infrastructure by Alex Russell

Bayeux and CometD: Open Source Comet Infrastructure
Alex Russell, Project Lead, SitePen

OK, this is a hard one to explain without going into a lot of background. And I felt a bit sorry for the presenter, because it appeared that half of the (small) audience was already familiar with the topic. Part of the social networking/CometD/Dojo “community.”

The presenter works on Dojo, and he’s got a great summary of CometD and Bayeaux.

Essentially, he’s trying to solve a fundamental problem of social networking websites. Each users has a page from the website in their browser. They need to send messages to each other — to each others’ browsers — but they can’t do this directly with peer-to-peer networking. Everything must go through a central server and the browsers must poll for messages.

This network architecture is difficult to scale and has high latency. High latency is bad. Users notice latency and they stop using the site.

So, what to do? Responsiveness matters, but the total amount of data isn’t a big deal.

There’s a protocol called Comet that keeps an HTTP connection open, but it relies on “brittle hacks.” (I think. Sorry if I muffed this bit.)

Bayeux is a new replacement protocol. It’s goals:

  • Browser native, no plugins
  • Easy to digest (simplicity is key, so that anybody can do use it)

What it is:

  • JSON-based
  • Hierarchical channels with simple globbing
  • Transport negotiated in handshake
  • Explicitly extensible
  • Stateless
  • Small number of verbs: handshake, connect, …

What it is not:

  • Authentication
  • Guranteed delivery

The client API is simple:
dojox.comet.publish("topic", { /* payload */});

CometD is the reference server implementation of Bayeaux, but there are more:

  • Jetty
  • WebSphere
  • Tomcat

Leave a Reply

You must be logged in to post a comment.

gears