Saturday, March 4th, 2006p>Alex Russell has coined a term for a flavour of Ajax that’s been getting more attention of late. Comet describes applications where the server keeps pushing – or streaming – data to the client, instead of having the browser keep polling the server for fresh content. Alex identifies several buzzworthy examples:
Comet uses a modified form of the canonical Ajax architecture:
As is illustrated above, Comet applications can deliver data to the client at any time, not only in response to user input. The data is delivered over a single, previously-opened connection. This approach reduces the latency for data delivery significantly.
The architecture relies on a view of data which is event driven on both sides of the HTTP connection. Engineers familiar with SOA or message oriented middleware will find this diagram to be amazingly familiar. The only substantive change is that the endpoint is the browser.
While Comet is similar to Ajax in that itâ€™s asynchronous, applications that implement the Comet style can communicate state changes with almost negligible latency. This makes it suitable for many types of monitoring and multi-user collaboration applications which would otherwise be difficult or impossible to handle in a browser without plugins.
Like Ajax, Comet’s a pattern that’s been around for a while, but Alex felt there was no suitable name for it, to help describe the problems and solutions growing around it: “(I)n the spirit of improved communication (and not technology invention), Iâ€™m proposing a new name for this stuff”
The article explains why Comet is better for users (responsive) and how it can scale. He also points out that Dojo has supported Comet-style architecture for some time.
As a sidenote, it’s interesting that 37Signals’ Campfire chat app went with polling as opposed to "Comet" architecture – it polls the server every three seconds for new messages. Since 37Signals presumably has similar constraints to Meebo or JotSpot, why would they prefer polling? More generally, when to use polling and when to use Comet?
(UPDATE: We recently interviewed Jamis Buck of 37signals and addressed the push versus poll question. The answer is less about technology and more about following the agile development process — more on that when we post the cast in the coming weeks. – Ben)
Remember the Push vision?
(A) new medium is arising, surging across the Web in the preferred, many-to-many way: anything flows from anyone to anyone – from anywhere to anywhere – anytime. In other words, a true network like the telephone system, rather than a radiating system like radio or TV. This new medium doesn’t wait for clicks. It doesn’t need computers. It means personalized experiences not bound by a page – think of a how-to origami video channel or a 3-D furry-muckers VR space. It means information that cascades, not just through a PC, but across all forms of communication devices – headlines sent to a pager, or a traffic map popping up on a cellular phone. And it means content that will not hesitate to find you – whether you’ve clicked on something recently or not.
– Wired, March 1997.
Posted by Michael Mahemoff at 2:06 pm