Infrequently Noted

Alex Russell on browsers, standards, and the process of progress.

Comments for Comet: Low Latency Data for the Browser


I wish we had a public version of AjaxWar up. Wouldn't it qualify as Comet?
This is great stuff. I work on DOD weather applications and have had to implement similar "hacks" to support this type of transfer. I believe we will be moving our stuff to dojo in the near future :)
by John Christopher at
Alex:

Will you be presenting on Comet at the Ajax Experience?

Isn't this just HTTP 1.0 style keep alive? I believe KnowNow implements this with HTTP 1.0... anyway... now we have something to call this. PeopleSoft apps use this style of communication for their Help Desk online chat apps (they OEM'd KnowNow's pub/sub tools back in 2001). Like XMLHTTPRequest, it's nothing new... but now we have a name for it... cool name btw.

Rich

Jeff: yes, I think AjaxWar qualifies

Rob: If you like!

by alex at
Rich: yes, sort of. The difference is that you don't initiate a new HTTP transaction for every datagram. Further, the client doesn't initiate the connections. In the HTTP 1.1 model, a TCP connection is indeed held open for multiple requests, but it is always the client requesting discrete blocks of content and then rendering them once the transaction is complete. Comet breaks these assumptions.
by alex at
So how well will a server cope with 1000's of open sockets? Obviously, the problem of the server having a thread allocated (for threaded servers) will have to be fixed, but assuming they are, and we learn the new models of how to deal with this, I'm wondering if servers will really be able to handle the sheer number of open sockets.

There's definitely something to be said for stateless ...

by Pat at
Pat: If your server is using a threaded network responder layer, you're pretty effed. OSes will handle that many open (10K+) fd's without any problem whatsoever, however the deamons that read/write from them often run into scalability issues. Select and poll are O(n) in these cases, and we really want something closer to O(1). Linux's epoll and FreeBSD's kqueue give this to us at a kernel IO level. Your web daemon has to take advantage of them, however.

This is where tools like Apache's mpm_event, Twisted Python, and POE come into play. They are event driven web daemons. That is to say that they don't allocate an OS thread or process per connection. Instead, they deliver data asynchronously to waiting listeners on an event driven basis. These are the kinds of tools that let your server handle this kind of load without breaking a sweat. If, OTOH, you go with something like a traditional Apache+mod_whatever infrastructure, you're just not going to scale.

Consider that your traditional web server is designed to take a request, satisfy it as fast as possible, and close the connection and you can easily see that they just aren't optimized for this kind of workload. I expect that all of our tools will lurchingly come up to speed for use with things like Comet, but the transition isn't going to be pretty for folks who don't grok the problems (and the potential solutions).

Regards

by alex at
time for yaws?

one day the crayon crowd is going to have to start thinking about profiling and performance. be it insane server loads (for comet) or insane load on the client (massive DOMs, canvas, SVG, etc), users may start balking at some of this frosting.

and once again i will offer the offtopic comment i always offer when i see "meebo" - you are insane if you hand over your password to a third party, and frankly the manin IM services should block them. meebo is not gaim or trillian - they connect directly with the authentication servers from the IM provider.

by grumpY! at
this page also provides a nice write-up of comet (before it was called comet)
by grumpY! at
Yet another great article (YAGA) Alex.

A quick question about "Even Apache will provide a Comet-ready worker module in the upcoming 2.2 release". To what module are you referring to as Apache 2.2.0 has been out for some time now.

I'd love to see a small demo of using Comet with Dojo if anyone has one.

As for handling large numbers of open connections I'd look into [Open]Solaris 10. It introduces a highly scalable and enhanced networking stack, which lowers overhead by reducing the number of instructions required to process packets. This efficiency also increases scalability, allowing more connections and enabling server network throughput to grow linearly with the number of CPUs and NICs.

by Steve at
grumpY!: is Google a member of the "crayon crowd"?

Just because your stock web server can't do it today, that doesn't mean it can't be made to scale. While we weren't looking the OSes picked up the slack and things like libevent got written. The only really surprising thing is that it didn't happen back when dialup users (whose longer-lived connections look similarly like Comet) ruled the roost.

The biggest scalability issue is going to be for people running poorly written proxies. Regardless, I don't think that reflects on the engineering ability (CPS resurrected!) of those building the servers to host Comet apps. The proxies will catch up.

You should give Twisted a long, hard look. It barely breaks a sweat on most of these workloads.

Regards

by alex at
That *is* a very good writeup.
by alex at
Steve: last I checked the event\_mpm wasn't marked stable yet? I hesitate recommending people use something like that when things like Twisted exist and are stable.
by alex at
alex- this is why i mentioned yaws. erlang has been providing insane threading support for some time now, the yaws graph is mind blowing. soon erlang will have smp. with multicore being the order of the day, erlang will either rise on its own or influence others. i would argue that yaws could handle this model gracefully.

is google in the "crayon crowd"? google gets a free pass because they have an unlimited hardware budget. that said, i suspect they are in fact doing tuning and profiling. the others...who can say? meebo's traffic is a rounding error.

by grumpY! at
grumpY!: I wasn't aware of yaws. I'll have to check it out. That also reminded me of the IO language that the author of LivePage was raving about recently.

/me revises ETech slides

by alex at
alex - this is the yaws vs apache graph i spoke of.

once again, people doing serious http streaming should look at yaws

by grumpY! at
I'd love to see how this stacks up against lighttpd, Twisted Web and the event\_mpm.
by alex at
>> I’d love to see how this stacks up against lighttpd, Twisted Web

ericsson runs telco switches on erlang, as do some other telcos, so my guess is that erlang would demolish these tools by a considerable margin, which is why yaws can stay alive long after apache has fallen over due to too many connections.

erlang runs as one process and manages its own threads. this is why it can offer "better than OS" thread performance.

by grumpY! at
FWIW, Twisted does the same thing. It uses CPS-style programming to keep everything in a single process.

I would still like to see the benchmarks = )

by alex at
The expensive web farm load balancers don't have much to do anymore.
by kramer at
You must be freaking kidding. (I wish I could use a swear word there.)

But this technology has been available for a long time and all you are trying to do is attach your name to it, by labeling it. Trust me, there are plenty of people already creating applications by utilizing the long lived http connections. Keep your stupid label "Comet" to yourself, all we need is more tards hopping on this bandwagon, like the Ajax one.

by Mike Lowry at
Mike: if you had read the post in it's entirety, you'll see that I both understand the origins of the technique and acknowledge them. I personally worked on a re-write of the mod_pubsub client 2+ years ago. It was old technology then.

What is different today is that it's being widely deployed.

As for my personal affiliation with it, I would only like to see its use become more common. I'm quite happy to continue hacking on Open Source DHTML in its various forms. I'm not trying to sell you or anyone else anything.

The only shot the web has at remaining open is for it to deliver better user experiences. If terminology allows us to do that before it becomes co-opted by any number of the large companies currently salivating at the prospect, so be it.

I'll be your whipping boy if it's better for the web.

by alex at
To go from client-poll to server-push it seems everybody has forgotten about multipart/x-mixed-replace. It is sitting there ready for use since years - no HTTP overhead, minimum latency. Php example on: php.net/flush look for comment from 20-Nov-2005 04:06.

AFAIK it is supported together with xmlhttprequest by firefox (but not IE6).

The problem will be the inter process message passing on the server though, as in today's scripting web (PHP, ASP, etc.) there is a copy of the program running for every client connection.

Second problem will be handling several thousand parallel connections at once.

Nevertheless, thanks for the cool article.

by Marcus at
Just a note to mention that Nevow Athena implements this kind of bi-directional client-server communication link. As far as coping with "1000s of open sockets", the problem isn't any more severe than any other kind of protocol where connections are persistent and long-lived; true, a lot of web tools today may not be geared up to handle this mode of operation, but this certainly wouldn't be the first time anyone has had to deal with it.
We included "comet" functionality into Millstone 3.0 UI component library released back in 2002. Basically you could you do any changes to components on server and they are automatically pushed to client through already open pipe. Unfortunately making this communication robust across all browsers is challenging. For an online demo and source-code, see "Game of Go" -demo on librarys online demo-page: http://examples.millstone.org/
Marcus: there is actually an analagous XML envelope available in IE. It's not multipart (which I think would be preferred), but it beats a kick in the teeth. It's also possible to poll responseText before the connection is closed. Regardless, I'm still more a fan of the hidden iframe technique since it allows you to set document.domain and avoid gobbling one of your precious connections when served from a subdomain.
by alex at
I wish I had this about 6 months ago! I had to develop my own push based system based on pushlets to implement a real-time auction system.

Good to know this type of functionality is moving forward :)

by ian at
Comet is a stupid name, that is the name of bathroom cleaner. Don't give up your day job guy. I will use your comet to clean my toilet and serve my pages of the web. Good technology, stupid name. Why not call it mullet or bandaid© or mr. clean© ??? I realize that AJAX is name of cleaner too, but at least stands for something, but comet? It is lame and annoying. I see no humor or irony in this. Excuse my English, I from USA.
haha...I missed the obvious cleanser pun until I read bronze_web's comment. The whole time I was thinking of a meteor shower of data coming from the server. I like the name, though it does seem to not do justice to the bi-directional nature of the communication link (i.e., if you're thinking of falling meteorites). Let's see if it sticks. :)
by Mike Ter Louw at
No this isnt new, but I don't think anyone was really claiming it was. But just like Ajax it is becoming more popular and can only benefit from things like this.

My company has been doing this for over 8 years in various ways. Starting off with Java applets/LiveConnect, and moving on to pure JavaScript implementations using both multipart replace and iFrame script tag methods.

It is certainly possible to acheive the necessary performance on a server, numbers of open sockets are not really a problem if implemented well, eg up to 30000 concurrent users. The problems are more related to the amount of data sent to the clients. Low message rates are fine, but to increase the messages rate you have to be more intelligent with the protocol and other techniques. With decent message rates overall bandwidth can be high.

by Martin Tyler at
I have read the JS source code for Jot Live. I find the nature of Comet is quite similar with AJAX. The only difference between them is that the Comet will start a new XMLHttp request immediately after the previous one finished.

Would it be a burden for the server? Due to the frequently requests.

by alexditto at
Jetty 6's continuations would probably work well with this technique.
by Codist at
http://orbitz-erlang.blogspot.com/2005/09/twisted-matrix.html

some more intelligent notes on erlang vs twisted

by grumpY! at
i wrote a very small chat application with nevow's athena. i use vhosts to overcome the 2- connection-limit per host (at least it seems to work). chat.sifu.co.at
Just call it a "Hanging-GET" because that's what it really is.

"Comet" (gag) is just a new name for Pushlets.

http://www.pushlets.com

Granted, the new name is intended for marketing purposes, but let's not forget it's the exact same idea with a different name. Both Pushlets and Comet both depend on a Hanging-GET (which I think is a better, more technology neutral term anyway.)

Don't forget also that this can't really be used as a generic eventing mechanism because it doesn't support gauranteed delivery. Most applications don't require it but there are a lot that do.

I'd like to see an implementation of HTTPLR

http://www.dehora.net/doc/httplr/draft-httplr-01.html

which woudl provide gauranteed delivery. It would require explicity acknowlegement of receipt, but with HTTP keep-alive, you'd end up talking over the same sockets anyway. So you still have the same threading issues to deal with but it's a more robust solution for a general client.

by Winter at
HTTPLR looks interesting, but that doesnt look like it could support Comet/Hanging-GET style push communication since all the gauranteed messaging is done on standard HTTP request/response headers. In comet you want to send multiple messages from server to client within the same response. Is HTTPLR going to address this?
by Martin Tyler at
I am really looking forward to your follow-ups on how dojo supports comet...I'm ready to try that already!
by John Li at
Please take a look at http://www.lightstreamer.com too. Several online demos are available.

Lightstreamer is a commercial poduct that has five years of maturity and very soon a free edition will be released. It can be integrated with any AJAX framework to implement true "push/streaming" capabilities, for updating a page with real-time data without relaying on any form of polling. Lightstreamer Server is highly scalable, due to its NIO-based staged event driven architecture.

Any feedback will be appreciated.

ICEfaces is a commercial product that deploys "comet" applications that are developed in pure Java (no JavaScript) using standard JSF components.

There is a free Community Edition available as well as a Professional Edition (commercial license). One of the advantages of the commercial version is that it provides a highly-scalable solution to the thread-consumption problem identified above related to holding connections open on the server.

Check it out for an example of a complete comet application development and deployment solution.

Online Demos: http://www.icesoft.com/products/demos_icefaces.html

ICEfaces information: http://www.icesoft.com/products/icefaces.html

Regards, Ken

TelePort is an Open Source product that supports Comet, JSON, SOAP, REST etc. etc.

(For the veterans amongst you guys: it is an evolution of the 2001 vcXMLRPC library)

It is released under the GPL and available on Sourceforge: http://sourceforge.net/projects/teleport/

For more information, wander over to http://www.javeline.org/modules/products/

Comet: keep-alive Ajax

  我在之å‰?的日志里é?¢æ??到:“当这ç§?冗余的数æ?®ä¼ è¾“å?˜å¾—相当频ç¹?的时候(比如我之å‰?所å?šçš„å?³æ—¶æ¯”分系统为了让æµ?览器第一时间得到最新的比分å?˜åŒ–XML数æ?®å¿…须以2ã€?3秒一次的频率ä¸?å?œç...

I think 'Comet' is as good a name as any other. Using Ajax on my kitchen floor did not make me confuse it with AJAX which I use in my work.

I do see why ppl immediately brought up performance issues with open connections. I'm sure this will be solved soon. AJAX spread so much faster since implementing only involved some php class and a couple lines of jacascript. But with 'Comet' it seems I need some apache module, or a similar technique outside of the reach of the ordinary web-developer.

Right now I would see the use of it in the support-admin system I'm currently working on, as it has just a few users (certainly not some thousand) and they work with the same queue of tasks in which the action of one support personell would need to influence the data displayed on the UI of the others.

I would really like to see some examples on how to implement 'Comet'. A few hints or a short summary would do, although to see a full tutorial would really thrill me.

Thx, rage

by rage at
I love this bleeding edge web development stuff. Does anybody know of any companies in the Boston metro area doing this kind of stuff, or recommend a way I might be able to go about finding out?

Thanks in advance.

by Derek at
Derek: Google may lend a hand there
by Curtis at
with ajax can't you just have a refresh in the javascript?, I know its not the same as having a listener to listen for events but it would solve the problem for many of the sites out there,

it seems a good method of pushing new data to the client, however with all these live connections once an event has occured won't the bandwidth die with pushing data out to 40000 clients at the same time?

so is there any support for this *currently* in PHP. if i understand the idea properly (eg: the server and browser send each other an xmlhttp data but keep writing data until the user leaves the page) then aren't you going to get two 'instances' of the php script (one that stays open to receive data from the browser, and a seperate instance of the script that simultaniously replies to a different xmlhttp call)? is there some way in php for the two instances to share data, other than writing and sharing the server harddisk?
by cc at
Theres also an approach to this using macromedia flash and liveconnect. Ive had this tech working for years and have recently added SOAP/WSE support so you can develop these push type apps with standard service oriented architecture methods.

http://www.kevin-mcarthur.com/Stream2.0 for more info.

AJAX in theory is an Acronym.

Does COMET really do justic to this technology.

True, Deja Vous' buzzwords ARE digestable and easier to remember, but perhaps it should reflect the DNA of the technology.

Pehaps, this could be an open invitation for all to come up with an encompassing term for this very spectacular technology.

"PUSHED" - should certainly be included.

I originally thought this story about "Comet" was a joke. This is basically exactly AJAX, except more clearly defined. The end effect is the author, Alex Russell, is going to make a bigger name for himself by mainly extending JJG's idea without keeping JJG's meme. What better way to *promote*. Not necessarily the best way to teach.

People are so concerned with being on the bleeding edge of data transmission technology that they forget creating buzzwords is secondary to understanding technology. The article is the epitome of a bad idea virus, although your article does point out JJG's insufficient description of using asynchronous data transfer.

Your article does absolutely nothing to differentiate between "AJAX" and your so-called "COMET." But that is neither here nor there. That is just me voicing an opinion.

So here is a fact:

You and Jesse James Garrett both have inaccurate diagrams to describe how XmlHTTPRequest works within a web browser and how web pages can use it to create a rich asynchronous experience. In all this hype of your new Web 2.0 buzzword creation, no one has pointed out your model is wrong. There should be two displays for each data transmission, one before the transmission and one after the data transmission. This is to show that the transmission is asynchronous. The first display would be of an hourglass or dots running in a circle or something. It's important for users to know when something has started and when something has finished, and that is typically considered part of the "AJAX Engine." It might also be desirable to "freeze" the state of the web page during the data transmission. Furthermore, the only difference between your diagram and JJG's is that you are more descriptive and specific of what the server-side processing is doing.

It's funny that the web is such a powerful medium to create a meme -- that your "Comet" idea is already catching on heavily is proof. Whereas JJG's AJAX acronym actually stood for something somewhat sensical, your Comet stands for nothing technical. I find that disappointing.

As for your endnote, "Common terminology acts not only as a shortcut in discussions between technical folks, but also as a bridge for those who may not be able to give a technical rundown of exactly how it works"; I would counter by pointing out there are a lot of common buzzwords that have different meaning to different people. The buzzword "Web 2.0" is a great example. It started off as one man's vision, and now it is a meme that means many things to many people. Coincidingly, trying to start a focused conversation about "Web 2.0" can't involve everybody.

(Sorry if I slammed you a bit here. I just felt the need to come across strong. I respect your role as a senior software engineer in http data transfer technology.)

by John "Z-Bo" Zabroski at
John,

I think you completely misunderstand the point of what I'm outlining here. Both in the sense that you assume that I'm somehow grandstanding for attention and that you somehow assume that on a network protocol level the technique isn't different. It clearly is.

Ajax transmissions are much like "traditional" http transactions in that both sides of the transaction are optimized for closing the connection as fast as possible. Whether or not the server batches state transfer is a different question, and can be accomidated in either model, but the Ajax scenario uses a much higher average latency to deliver these batched state changes. This often leads to stale UI context for making decisions.

As for your discussion of "Web2.0", I'm not sure it's worth rebutting. Instead of even obliquely attempting to describe a technology or pattern it was plucked out of the ether as a marketing term to describe a conference. I certainly hope that with "Comet" (or whatever it winds up being called eventually), we will have created enough technical context and consensus for the term to be useful in discussion. As you perhaps attempt to point out, that is by no means a foregone conclusion, but to bucket my attempts to smooth conversation with the coining of "Web2.0" seems a snarky stretch at best.

Regards

by alex at
I probably should have crafted a friendlier statement. Re-reading what I wrote I probably sounded like a jerk, or, in all capitals, JERK. I am sorry and apologize. My lack of finesse must have seemed appalling.

I understand what your overall thesis statement is: Most people have assumptions about the kinds of transactions that can be done to give web sites the richness and responsiveness to rival Desktop applications... and it is time to break those assumptions because they limit one's creative vision. Alex, as a senior software engineer, you need a bigger canvas to apply your paint. I share your sentiment; whatever problem "Ajax" can't clean, grab another cleaner ("Comet") to rid yourself of the messes associated with bandwidth and hourglass-waiting.

In terms of Ajax using a "much higher average latency" to deliver state changes, half of all state changes are done without a client-server transaction: Client makes an action, and the event is an input to the Ajax engine, which then calls a state change back to the Browser UI (hourglass, dots running in a circle, &c) before making an XML request to the server. That's entirely a client transaction, between the Browser UI and Ajax/Comet client.

I am also not sure that the client-server transaction has a "much higher latency" to deliver the second state change, which is the end result of a client making an action. There is always ways to lower latency if it is a worry. On the server-side processing end, caching data can help.

I have also seen so-called Ajax applications with continuous server-side connections, despite the fact that Jesse Jame Garrett's model shows discontinuous server-side activity.

What you are describing is basically the server pushing data to clients who asked to be notified of new data. (In my opinion, the action of asking to be notified can be seen as an Ajax event.) In terms of latency there, there is still going to be latency in many transmissions because most routers are not optimized for broadcasting. Latency could be reduced if routers could split TCP/IP packets at appropriate hops and forwarded each split to a destination address. I don't believe most routers support this functionality. Yet your "Comet" idea would benefit greatly from the reduced bandwidth necessary to transmit the information. There's many ways latency is effected between client, network and server.

Take care and best regards =)

by John "Z-Bo" Zabroski at
I wonder just how instantaneous any of this data really needs to be? Are their really applications in which the difference between 1 second and 5 is life and death. I would think the latency introduced by the human consumer of the data will dwarf any advantage Ajax gives you over Comet. Or is there another benefit to the technology I'm missing here? I've written an AJAX based chat application and have been very satisfied with a gradually decaying Ajax polling mechanism.
by Derek at
Derek: If you spend any amount of time thinking about chat in the pantheon of collaborative apps, it pretty quickly turns up as a corner case. Not only is it append-only, stale context rarely means a bad decision.

There are many forms of collaborative apps that need better responsiveness (see JotLive, for instance), and even your chat app could benefit. 5 seconds to get a message that might have taken 5 seconds to type is pretty shitty total latency. Comet allows us to do better.

Regards

by alex at
Good points Alex. Its so exciting to be able finally be able to do any of this stuff. I remember looking around 2 or 3 years ago to do stuff in the Ajax model and Pushlets (Comet) was a very viable candidate. I remember spending days if not weeks trying to solve that annoying IE Iframe click issue to no avail! Its great to see people finally pushing the envelope.

I remember reading a post on one of the Comet blog entries marking a pretty convincing argument that Comet may actually be a lower bandwidth solution when you factor in the cost of sending around all of the HTTP headers associated with an XHR request. I would love to see a detailed examination of the costs associated with each.

by Derek at
So far so good. Where is the working "Hello World Example". Your Code-Snipp doesn't work. rg. st.
by Stevie at
Great article. Finally someone named the technique many are working on, including me. I created a real-time multi-user environment with "Comet". Check it out: http://dutchpipe.bubblestart.com/ As for scalability, it turns out to be pretty light. When 'nothing' happens, it uses almost nothing. However there will be a limit of users which is lower than normal webapps as from a certain number of users it would become kind of a distributed denial of service attack. But this is just for starters. There's so much to say on the subject. Hope your name catches on.
by Lennert at
I'm not sure this technique needed another buzzword, but then comet is more catchy than "long polling"

Jetty 6 has a continuation feature that support scalable long polling within the java servlet API, so I guess Jetty 6 is Comet ready. This technique scales better than thousands of clients polling every few seconds! http://www.mortbay.com/MB/log/gregw/?permalink=ScalingConnections.html

Nice to hear about AJAX from AJAX king. But it would be more informative if you would have informed about Framework you have used in developing meebo.com
by Gaurav at
Just look at:

http://schumann.cx/ircg/

So - to be fair, "comet" should be renamed to "ircg" because the server-push technology is like about several years old and has been used in many projects - from flasg based messengers to html - irc gateways etc.etc.

by Holger at
The technology is great, but I see a few bumps before success.

Many firewalls stop long living HTTP connections :( , I guess that you allways have to fall back on the old poll thing again.

by Daniel at
Alex, when you say "there is actually an analagous XML envelope available in IE. It’s not multipart (which I think would be preferred), but it beats a kick in the teeth. It’s also possible to poll responseText before the connection is closed. Regardless, I’m still more a fan of the hidden iframe technique since it allows you to set document.domain and avoid gobbling one of your precious connections when served from a subdomain.", can you please describe what that analogous envelope is?

Also, I'm interested in more information about the document.domain fix for multiple connections. Right now I'm using a Java applet to open long-lived connections, and when more than one page has an applet the entire browser grinds to a halt. Does the iFrame technique solve this issue? I'm also considering using Flash applications as well.

by Scott at
Comet, "the new ajax" ? well ... check out this : http://www.pushlets.com/

And i m usin it for 5 years :) ... i confirm that they are problems with some network equipement like firewall who cut off the http persistant connections .

by tomtom at
COMET and j2me ?
by Foward at
Hey Alex,

Congratulations for the wonderfull DOJO. Keep on doing what you're doing, don't listen to the stupid voices in the crowd. Some people don't see that it doesn't matter how it's called "Comet", "Pushlets" etc. So what if it's the name of some bathroom cleaner. The only thing that matters is that things move on, the way they should. The web is not only for java or asp or any other standalone language, it is for all of them and for also all of us. Keep on rocking in the free world. Doru

by Doru at
I wrote an Instant Messenger in Java about a year ago. I used http protocol so that messages could tranverse thru proxies and firewalls. Except the client is a java swing app instead of a browser, all of the others are just the same as Comet. There are many problems. First of all not all proxies and firewalls support long-lived http connections. The second is the serverside thread. You can rewrite a light-weight web server and using 'select' method to avoid threading problems. The client side first needs to initialize a http request. And after initializing, it keeps using this http connection for polling messages from the server side. Another problem is how many sockets can a server support. This depends the underlying OS. I did not test my IM to see the output. It is also very easy to cluster. Before reading your posts, I did not it was so popular a technique. I should look at the other solutions existed. Thanks alex for standardize the concept though I don't think the name 'Comet' is good.
by William Chen at
Of course, in my IM, I only used comet when the two chating users are both behind a proxy or firewall and they don't belong to a same intranet. As for others, if one of them is directly connected to the internet, then it will launch a light-weight web server and the other one will communicate using comet. If both of them can connect to each other using TCP, they will connect to each other using direct TCP connection, eg. if they are both directly connect to the internet or they are both behind a proxy but belongs to a same intranet. JXTA is a similar concept except it is a higher abstraction. In this very case, JXTA probably uses http tunneling to wrap datagrams.
by William Chen at
A new concept - REVERSE AJAX

新ã?—ã?„コンセプトを勉強ã?—ã?Ÿã€‚

Reverse Ajax Comet Queryies

Reverse Ajaxã?®æ„?味ã?¯Ajaxianã?‹ã‚‰ã?®èª¬æ˜Žã‚’見れã?°åˆ†ã?‹ã‚‹ã?¨æ€?ã?†ã€‚ The big new feature is Reverse Ajax: DWR 1.x allowed you to asynchronously call Java code from Java...

As I read this I realized that I've been doing exactly this for many years. I had build a real time bond trading system that need real time updates to the browser -- so having an open connection simply waiting for data worked perfectly. Never thought about naming it -- Comet seems very appropo if you think about shooting data out to the browser.
Macromedia Flex kind of already solves all this don't you think?
by jason at
Comet Is the New Ajax

Renkoo Beta

Originally uploaded by Ben Ramsey.

This time last year, a single word began a revolution in Web design. Coined and published on February 18, 2005, by May, the word “AJAX” was on everyone’s lips. It soon...

I don't really care about the buzz word that it's called. Comet is as good as any; my question is "How do you do an Ajax/Comet push?" What does the code look like? If I was trying to use Apache 2.2 how would I go about pushing updated data to the browser?

Thanks

by Shaun at
Are there any available resources such as websites, books or articles/tutorials that teach how to implement COMET? I'm looking for a topic for my thesis and I think that this will be a good one. Also, can you give suggestions of useful web applications that I can create using COMET. Thanks!
by Paulo Tioseco at
This is a great article. However, I want to see code references. In terms of Dojo, what is the technology running on the server? Could I look at your bind implimentation and see if it could be ported to a .Net environment?
I wrote a comet based IRC client that is low latency and event based... all very nice I'd like to show it to you given that Paul wrote a jsbot it might be something you guys would like.. email me..
by Pedram at
Comet - 下一代Ajax
The problem with the word comet is that it is not as easily googlable as ajax. The beauty of the word ajax is how googlable the word was. I have regrets that it wasn't named comt, or commet (signifying the meeting of two in the web?)
by kaddar at
Kenamea's bi-directional messaging system is also "Comet-ready" and can scale up to support thousands of connections.
Maybe I am missing something, but this technique didn't work for me when I tried it about 3 years ago. I used IE and Tomcat to create a live console for a production system which generates dozens (sometimes hundreds) messages a minute. The problem was that from the IE point of view this was like downloading one huge page, so it never released the storage and was getting slower and slower. I tried breaking and restarting the connection every n messages, but when IE was releasing the storage it brought the PC to a halt for a second or two, which was very annoying. I ended up using an applet with LiveConnect to handle all communications between JS in the browser and Java on the server.
by Gregory at
Sounds similair to the old non-parsed header technique wherein you use the multipart/x-mixed-replace mime type in your response and set boundaries. I guess you combine that with ajax and voila you have persistent client server communication. Or is the "slow-load" method different?
by Paddy Hannon at
I like Winters term 'Hanging-GET'. It reduces all the mystery and confusion to something small and simple. I have to admit however, if it were not for the buzz-words 'Ajax' and 'Comet' I may have never stumbled upon these good ideas. Thank you Winter, Thank you Alex.
by Jared at
Seems as though some responders are not reading before commenting. I may not know my head from my ass; however, I have read the conversation prior to this comment.
  1. REGARDING THE TERMINOLOGY TOPIC ~ and, considering the comment = “Common terminology acts not only as a shortcut in discussions between technical folks, but also as a bridge for those who may not be able to give a technical rundown of exactly how it worksâ€?;

Response: I agree that a "term" is a positive thing as far as it facilitates communication and efficient collaboration. Yet, developers and "developers" are way too sloppy and immature with all of these labels. With web development, I think most of the new buzzwords are merely new skins placed around core development principles; every time a new angle is demonstrated, where the implementation has a degree of exposure, a new skin is stretched around what is merely a particular arrangement of the craft's available materials, applied with a standard handful of tools: tools that are common to the craft of development, as other crafts have their own array of core tools. A few weeks ago, a Urologist friend of mine had to make do with a pair of bolt cutters in order to finally remove a sexual device that was stuck on some poor dude who ended up in the emergency room after, god knows what, went wrong in bed with his girlfriend. Anyway, he wasn’t sure if the bolt cutter approach was ever taken before, let alone ever needed, but he didn’t go inventing and marketing some buzzword for the method. I think if he had, it would not only confuse a pretty basic solution, but would probably make him look a little ambitious and perhaps a bit amateurish that he thought his approach was so “break-through,â€? that it needed its own buzzword and subsequent, industry-wide, best-practicesâ€? modernization rollout.

The web context, and the developer profession, seem to foster a particularly zealous and obvious approach. It reminds me of times when I was young and played the trumpet in school. When trumpeters get around each other, there are always some, who must demonstrate their entire arsenal of talent, and, show off their cutting edge equipment. The higher the stakes, the more this seems to happen, and will more likely exhaust players chops and make everybody feel all competitive and intimidated, instead of cohesive and in 'tune.' These habits seemed to come most, from those with the least virtuosity and experience. Relating back to the developer’s world, there seems to be a lot of competition around – or, at least a lot of developers. On top of that, we see these sporadic start-up ideas pop up out of nowhere and get sold for 350 million dollars. So, perhaps these 'buzzwords' are stretched over our work, whenever possible, in hopes they’re mistaken for inventions, and, increase the odds of investment capital coming our way? Maybe there are too many developers around, so, we hear a lot of horn blowing going on? Personally, most of the new terms bother me; and, admittedly, they do sort of intimidate me and do sometimes make me feel like I’m not clued in or not keeping up. Often, though, when I do get around to making sure I know what's up with the new buzz, it ends up to be some 'meme' that your average AOL customer might be impressed by, while, real developers will see it to be no more exceptional to developing than a scale is to trumpet playing.

A previous post suggested that the process of coining new buzzwords for everything, somehow contributes to an open source environment, while making it more difficult for the big players to snatch up the technology and brand it. Conversely, I think that this excessive labeling and equally excessive wrapper creating and promoting, are attempts to grab ownership of whatever "layer," or intellectual credit one can, from the tools we all share. Is it fear and/or intimidation that promote this?


Although I don't think the "COMET" idea is any more innovative than the "AJAX" idea, I do think the “PUSHâ€? related option that “Cometâ€? deals with, is relevant and sort of needed if thin clients are to approach the kind of functionality we’ve become used to with our applications. But, all this talk of different servers and wrapper products (i.e. weekend projects) don't seem relevant to me; perhaps I'm missing the point, but, the server doesn't seem anymore relevant to this topic, than a reliable server is to any web-served application related topic. Whether a server can handle 100 threads or connections, or a billion, it doesn't matter; because, as long as the number of threads and connections is an issue at all, then the solution is not correct. With scale, isn't it all relative? I'm sure the company scoring a billion profitable transactions a day doesn't want their server to max out and freeze up, anymore than I want my server to fail, if my piss-ass site tops 100.

I want a push solution for applications that require real-time, n-user interaction. I haven't been too encouraged by the load-related stats I've gotten from small experiments where only a hand full of clients are “pollingâ€? the server every .5 to 10 seconds. So, yea, It seems to me that we need 'multi-cast' like callbacks - from the server; yet, with the “bussâ€? approach this articles suggests, or any metronomic call approach (which necessitates some kind of object/page-load/threading each time), is not really solving the problems that arise with the “pollingâ€? option.

So, I think a 'comet' type technique is relevant, but must cooperate, collectively, with the clients, in a way that doesn't persist connections, doesn't use any objects that must be hosted by the server if scoped such that instantiation must happen for each browser instance, or worse yet, callback method, that .is required.

I have some ideas for ways this might be done, and I'm sure a million of you developers out there do as well.

But all the discussions seem to be so focused on talking about these buzzwords and specific wrappers or script libraries that I usually don't bother. Not only do I not have time to try every method, within every wrapper that someone makes - frankly, I don't want to. We know how to call a method and make use of an object; why don't we figure out good solutions and strategies, and then perhaps see if there are a few helpful, pre-fab, fancy-named, custom-skinned, buzz-worded, wrappers (services/proxies) etc. out there that are quality and can save us the bother of creating our own?

Thanks for the discussion De

Sorry about the above formatting - I would appreciate it if someone could fix it.

thank you

Alex, if I am not mistaken, you are saying that mod_pubsub improves the scalability of servers using Comet. I was just wondering how exactly does mod_pubsub accomplish such a thing. The web server still has to manage the constantly opened connections even with mod_pubsub installed, doesn't it?
by Kevin at
hey Kevin,

Sorry I didn't catch your comment earlier.

Despite it's name, mod_pubsub was never actually an Apache module. All of the versions which I saw were either implemented in Perl using sockets or atop Python's old asyncore infrastructure. In 2004 an upgrade to the core Python version started to employ Twisted Python as the network-level responder. Twisted improves the performance of these kinds of things by making sure that network I/O never blocks and doesn't require a thread or process per request. Things need to be written differently to operate on top of Twisted, but once that's done, holding thousands of concurrent connections open at a time is no longer crippling.

Regards

by alex at
Alex, I am curious how does this client/server 'event' flow map onto HTTP 1.1 Request/Response?

In particular is each new browser 'event' a pipelined HTTP request to the server? and is a particular 'stream' of server 'events' considered part of the response to the most recent (server processed) client HTTP request?

Thanks

  • larry cable
by Larry Cable at
grumpY!: is Google a member of the “crayon crowdâ€??

They most certainly are, in fact they have a VIP membership. I curse them everytime I have to kill my Firefox because it's using 200Mb of memory because of GMail.

by anonymous at
Where do I see this going? I don’t know of a better set of technologies for building Comet apps. One possibility is massively multiplayer online games for browser-based clients. All types of internet-based collaboration and instanct communication apps could use this great hybrid as well.
Is there any limitation to use comet?
by Akhil at
Very nice to see this finaly be used by the community. If you want a great example look into the Lycos chatclient found at chat.lycos.co.uk its been using this method for communicating since 1998.

:)

Interesting article... I found the comments more enlightening, though.  It would indeed be nice to have a more technical, practical discussion of usage rather than general what-if and wait-for-it.

While I see the benefit of having a term for it, I agree with the people who find 'Comet' to be a goofy and unhelpful one.  The industry is full of stupid acronyms that are pretty unhelpful (Service-Oriented Architecture... aren't most architectures service-oriented?), but at least they're on track.  'Comet' doesn't even start to give an impression of what you might be referring to.

'Hanging GET' clicked for me; while there was enough discussion of what this was about before that was said, it's the most descriptive moniker I noticed in this thread.

Conclusion: It's nice that you're fostering discussion... but please, next time you try to establish a buzzword, do us all a favor and pick one that makes sense.  If you're going to rename a long-established set of technologies, at least improve on what's there.

by E T at
Like it, the concept even if it is Re-freshed Push, and the word too - Comet makes sense on a lot of levels. I vote for the word TIDE to represent the next re-boiled artefact of the old web that needs a sexy term to spark reincarnation.
I think comet is best for .net application and ajax is gloabl for evry kind of techonogy domain. so ajax is better then comet
by Rocky at
Sounds similair to the old non-parsed header technique wherein you use the multipart/x-mixed-replace mime type in your response and set boundaries. I guess you combine that with ajax and voila you have persistent client server communication. Or is the “slow-loadâ€? method different?
Live Page-View Counter, Comet server and JSON-push

Overview A page-view counter or hit counter is a mechanism that displays the number of page-views on an HTML page. It uses a server side of script that counts the page-views, dynamically generates an HTML page on the server side,

I would appreciate it very much if ther would be a simple "Hello World"-example. Sounds interesting, but I haven't a clue how to use it. I would only need it for about 10 concurrent user, so I don't care about server performance.
by ernst at
Sounds similair to the old non-parsed header technique wherein you use the multipart/x-mixed-replace mime type in your response and set boundaries. I guess you combine that with ajax and voila you have persistent client server communication.
I like the word LazyHttp better, also I've made a couple of implementations which can be found from here...
Hi,

I know I'm a little late to join the conversation, but I've been discussing the methods Comet with some of my colleagues and the key question that came up was proxies will buffer the content in a few KB of data before sending it to the client.

If you have an application that requires only small pieces of updates (i.e. a chat client or a price for a trading system) the proxy is going to buffer a large amount of updates before it's sent through.

We've only been able to test in a bespoke Java application and bespoke server, rather than Comet-type approach using Apache (or bespoke server) and JavaScript - but I expect the same rules apply?

Does anyone have any thought or work arounds to these issues?  Or am I completely wrong in my assumption?

(Padding the content if the proxy is in use may not be a great idea because the buffer size could be different from sysadmin to sysadmin).

Remy,

Never too late ;-)

In Cometd (http://cometd.com), we're using "pluggable" envelopes for most connections in which we you easily add padding, but if you're using long polling, connection close (when the data is sent in the first place) should cause any sane proxy to forward on everything in the cache. If an RST doesn't cause a flush, then there's something really really wrong.

Regards

by alex at
i have a classical ajax page.. and now i'm trying to make a comet page.. what should i change on my ajax page to make it into comet page? thx all.. 
by learning at
i thought it was the renkoo folks who built/open-sourced Comet in the first place. i could be mistaken.
by Peter at
First of all, it's IMPOSSIBLE to submit comments in IE7... The "WYSIWYG" editor is INVISIBLE... ;) Second (and my reason to post) is that I actually did an implementation of this a couple of weeks ago which can be seen at http://ajaxwidgets.com/nnug/ The presentation is in NORWEGIAN but if you Download the link (up left) you'll get a Visual Studio solution which you can download that contains a "rudimentary" implementation of "Comet" (or LazyHttp which I prefer to call it ;)

PS! [Shameless plug...] And while you're at it if you're a .NET developer, make sure you check out; http://ajaxwidgets.com ;)

.t

Peter,

The first implementations that I'm aware of were from a company called KnowNow. You can buy their super-scalable Comet server or Lightstreamer's if you've got big apps and a big-ish budget.

KnowNow open source'd mod_pubsub at one point, and one of their founders is also a founder of Renkoo (Adam Rifkin). It's no surprise then that Renkoo uses a Comet server based on the published mod_pubsub protocol, but that work came later than KnowNow's pioneering implementation.

Regards

by alex at
Thomas,

IE7 commenting should be fixed. I've updated the editor to use the AOL CDN hosted build of Dojo 0.4.2. Let me know if you're still having problems with it.

Regards

by alex at
It works now ;)Though I had to choose "Normal" (up right) before I could start typing... Anyway the reason I'm replying now is due to my new blog about it at my signature... :)But I still REFUSE to call it anything else than LazyHttp... ;)
Comet, it makes your teeth turn green. Comet, it takes like gasoline. Comet, it make you vomit. So get some comet, and vomit, today.   Sorry, I couldn't resist (and I couldn't get the darn song out of my head!)   Seriously, mixing polling and comet for reverse ajax would seem to address problem of long term connections with comet vs bandwidth and resource consumption with polling.  Instead of polling every second or five second, have a 30 second timeout on your comet and reissue the request when you get a response from the server (timeout or otherwise).  This would be like a 30 second poll that would respond as soon as there is an event.  Then it is just a question of tuning the timeout.
by Graeme Black at
nice..it looks great but is there a helpdesc or something like tutorials about Comet ?

I want to make my first implementations on my website. So I'll be glad if someone can show me trial.

by lukas at
is there some exemples of Comet used ?
by fotka at
Isn’t this just HTTP 1.0 style keep alive? I believe KnowNow implements this with HTTP 1.0… anyway… now we have something to call this. PeopleSoft apps use this style of communication for their Help Desk online chat apps (they OEM’d KnowNow’s pub/sub tools back in 2001). Like XMLHTTPRequest, it’s nothing new… but now we have a name for it… cool name btw.

Serg

by Serg at
I would really like to see some examples too on how to implement ‘Comet’ . A few hints or a short summary would do, although to see a full tutorial would really thrill me.I want to make my first implementations on my website.
by Konin at
Personally, I'm loving the new emerging browser technologies and the emergence of old technology coming back to the forefront. Good ideas don't die quickly. The whole resurgence of the browser wars etc. is hopefully a sign of things to come within IT – we really need a new late 80's early 90's vibe in IT. It's all become way too corporate, and way too 'same old, same old.' I'll get really excited if Amiga came back into the market – that would be awesome!! And hopefully computer games would get exciting and creative again too.
I am trying to warm up myself with AJAX. It seems that I can use it to add flavor to my site without sacrificing the characteristic of being crawlable.  At first I was kind of hesitant to use it but as I use it along wit the newest Yahoo Connection Library, I always end up making another reason just to use AJAX.  By the way, have you checked out the latest Yahoo Connection Library?  I wonder where I can find the tools for Comet.

 

Despite it’s name, mod_pubsub was never *actually* an Apache module. All of the versions which I saw were either implemented in Perl using sockets or atop Python’s old asyncore infrastructure.
People are so concerned with being on the bleeding edge of data transmission technology that they forget creating buzzwords is secondary to understanding technology. The article is the epitome of a bad idea virus, although your article does point out JJG’s insufficient description of using asynchronous data transfer.
by dziecko at
I would appreciate it very much if ther would be a simple “Hello World”-example. Sounds interesting, but I haven’t a clue how to use it. I would only need it for about 10 concurrent user, so I don’t care about server performance.
What is the better to use : AJAX Comet or xmpp.
I found it at topic with intresting name "Comet vs Ajax".

[..]AJAX means Asynchronous Javascript And XML - it's a way to use the web as a platform to serve applications in the same way that programs work in Windows or Mac OS.

It's a hot item right now because lots of developers, programmers and web users are excited about the possibilities of what can be done with AJAX as opposed to just web pages that submit information to a backend script for processing and return data. The idea is that all that can now happen on a single page (and that greater functionality and flow can follow from that).[..] I'm thinking why there is nothing about Comet. Comet isn't popular at web discus groups. There inn't a lot information about Comet on the web.

I was trying to use it but nothing advanced.

Leo en el blog de Alex Russel la definición de comet. Podría decirse que Comet se diferencia de Ajax en que en Comet la comunicación es fluída, es decir, el servidor en cualquier momento puede enviar información al cliente, y no como respuesta a un evento como normalmente ocurre en Ajax. La diferencia en los diagramas de conexión puede apreciarse en la siguiente gráfica !
by andrus at
I would appreciate it very much if ther would be a simple “Hello World”-example. Sounds interesting, but I haven’t a clue how to use it. I would only need it for about 10 concurrent user, so I don’t care about server performance.
by manish at
I like Winters term ‘Hanging-GET’. It reduces all the mystery and confusion to something small and simple. I have to admit however, if it were not for the buzz-words ‘Ajax’ and ‘Comet’ I may have never stumbled upon these good ideas.
What is the better to use : AJAX Comet or xmpp.
The Lycos chat uses comet for a long time, but is it really better in performance than other languages?
by Marc at
Will you be presenting on Comet at the Ajax Experience?
The industry is full of stupid acronyms that are pretty unhelpful (Service-Oriented Architecture… aren’t most architectures service-oriented?), but at least they’re on track. ‘Comet’ doesn’t even start to give an impression of what you might be referring to.
Sounds similair to the old non-parsed header technique wherein you use the multipart/x-mixed-replace mime type in your response and set boundaries. I guess you combine that with ajax and voila you have persistent client server communication.

I want to make my first implementations on my website. So I’ll be glad if someone can show me trial. nice..it looks great but is there a helpdesc or something like tutorials about Comet ?

Having a buzz-word to describe a concept is a pretty good tactic for making a technique widespread. I myself am now using AJAX because I kept hearing it referred to across the web, and it intrigued me. Googling the word 'AJAX' just to find out what it meant was the first step to learning about and eventually using it.

And while I might have not remembered the concept had someone explained it to me in tech terms, the term "Comet" is a good visual association/mnemonic device for a right-brainer creative type like myself.

Kudos. I hope the word catches on, and poo poo on the nay-sayers.

by Mist at
I am working in an IM project and the client is web-based. I did everything using common AJAX techniques and soon I realized that just polling was not a good approach for many reasons. Then I just got the idea to make the server works in a pro-active way registering events and letting user agents be notified (acting as listeners) when some event is shot. As all of you already know, in order to do that using our old-fashion HTTP 1.1 I had to overcome the "request-response" behaviour, making server keep a connection and only sending it back when an event happens. I was very proud of this solution when I decided to look at the web for something similar. Suddenly I realized that many of you have already had this idea, or others similar, during these years. Anyway, I feel part of this community. In addition it is very important to coin a term like this helping it to be spread in IT industry!! Congratulations for the article.
by Fabio Carvalho at
In a nutshell, Lighttpd appears to have better support for Asynchronous transactions (aka AJAX) and also built in support for AJAX push technology (aka COMET, which I will expand upon in upcoming posts. In the meantime checkout Alex Russel’s Blog, and the COMET page in Wikipedia) which we would be relying much upon in the Octabox service. The performance gain in those areas have convinced several prominent web-applications to go the Lighttpd way (Youtube, Meebo and Wikipedia among others)
by alveo at
The expensive web farm load balancers don’t have much to do anymore..
A quick update to this thread, since this is where it all started (in terms of the name Comet at least)...

Caplin Systems (http://www.caplin.com) recently released a free version of their high performance Comet server which is used commercially for many financial applications around the world.

The free version can be found here - http://www.freeliberator.com - and has plenty of documentation, examples and tutorials both online and as part of the kit you can download.

Plug over :)

Like it, the concept even if it is Re-freshed Push, and the word too - Comet makes sense on a lot of levels. I vote for the word TIDE to represent the next re-boiled artefact of the old web that needs a sexy term to spark reincarnation.
Great information! Now I know what Gmail Talk is made of. But I noticed that you only mentioned the positive side of Comet. Are there any negative aspects of it? When is it not applicable for use?
Thanks for very interesting article. I really enjoyed reading all of your articles. Keep up the good work. See You
by Crochet at
It seems that all these things make challenge on the browsers.
I think you are right but this is not good solution for me
a quick note on comments: I've been deleting (or not approving) those that don't add to the conversation on this particular post. That policy will continue. Say something interesting, useful, or provocative, or don't say anything at all.
by alex at
I really do not understand how does it works.
I wonder if Google is planning on implementing Comet ideas with their new applications that are (hush hush) supposed to let you (somehow) access your e-mail offline; and access AIR like applications off-line (in fact, this is something I think Adobe is trying to create more and more). I don't mean Comet exactly, I mean something about the theory. I may not know what I'm talking about, but I certainly think there's lots to be said about this concept itself.
I think its time we had a new term for the whole HTTP streaming push group of techniques, what with emerging technologies such as HTML 5 Web Sockets, Server Sent Events and other techniques for pushing to browsers such as Silverlight and Flex. New technologies like StreamHub Comet Server are using a best-fit approach where they use Comet, HTML 5, etc... to achieve the most reliable connection to a browser. Maybe "Web Push"? Or on the theme of detergents Cillit Bang?
by Ajaxxa at
Great article, you show many arguments. Is there some more information about Comet in wikipedia or somewhere ?

A lots of programmers (me too) are realy excited about the possibilities of what can be done with AJAX but there is still not enough info about this technic. Actually web users know something about web2.0 and it's hard to understand for most of them. AJAX is great but in fact at advanced projects it is too slow. I have some problems too with a few browsers. That's why I was interested about comet. Comet is great alternative for Ajax but it is very hard to find more info about integration with populat projects (for example google API, open source CMS).

I think we must wait for that technology to be more popular.

Hey Alex, you rock. We've implemented a full comet server using the Bayeux spec for the .NET platform; it's called WebSync. Check it out sometime if you have a couple minutes - www.frozenmountain.com/websync.
I’d look into [Open]Solaris 10. It introduces a highly scalable and enhanced networking stack, which lowers overhead by reducing the number of instructions required to process packets. This efficiency also increases scalability, allowing more connections and enabling server network throughput to grow linearly with the number of CPUs and NICs.