Concrete Comet Examples

by Alessandro AlinoneOctober 23rd, 2009

When writing about Comet technologies, sometimes we tend to be a bit abstract and theoretical. In this case, I would like to focus on concrete working examples. So concrete that they actually run inside this very article…

Stock Prices

Solutions for the online trading of securities were the first to adopt Push Technology and the Comet paradigm. In my case, it was actually the requirements of online trading systems that drove the technology. Back in 2000, when I started designing and prototyping Lightstreamer, I had had strong inputs from banks that wanted to get rid of Java applets. At that time, real-time market data (stock quotes and news) was delivered through the Internet to thick desktop applications or to Java applets running inside the browser. The trend of moving from desktop to browser-based applications was already massive and, at the same time, the decline of Java applets had begun (for some well known reasons, including: incompatible runtimes, start-up slowness, expensive maintenance, layout mismatch, etc.).

Nine years ago, the only ready-made solutions for pushing data to a browser without using applets or plug-ins were Pushlets (open source) and Lightstreamer (commercial). Starting from 2006, when the term “Comet” was coined, many more players, both open source and commercial, has come into the arena, making modern Push Technology more and more visible and recognized in the mainstream.

Banks and financial institutions are still the most demanding Comet-technology consumers. Their requirement of pushing real-time market data to the browser is still there, with additional requirements of low latency, high scalability, bandwidth throttling, and the support of multiple client-side technologies, including Ajax, Flex, Silverlight, and iPhone.

In recent years, many online gaming companies, especially in the UK, have found a great technological ally in Comet. Spread betting in particular, which is often on the boundary between finance and gaming, shares the same requirements of more traditional online trading applications. Many other types of games and auctions are progressively adopting Comet technologies.

The live example above is based on the most typical Lightstreamer demo. You can check out the full source code and explanation.


To the left you can see a basic, fully-functional chat application. It is implemented in pure HTML and JavaScript and is able to deliver each message with zero latency (that is, no round trip to retrieve a new message, thanks to streaming or long-polling, depending on the environment).

Chat applications have often been considered the “Hello World” of Comet (even if in the past I preferred to publish an actual “Hello World” application…). One of the first players to propose a full-fledged messenger application based on the Comet paradigm was Meebo. Previously, web chats relied on page refresh or applets/plug-ins. Soon after the success of Meebo, the arena of new generation chats/messengers quickly became crowded. It is interesting to notice that the widespread success of Comet chats arrived with the in-house engineering made by the major social companies. Google Talk inside Gmail and the Facebook chat are two clear examples.

Chat and messenger Comet applications are much simpler and lighter on requirements with respect to online trading Comet applications. For instance, bandwidth throttling and very low latency are generally not really necessary. Even if the number of concurrent users can be higher than trading applications, the event throughput for each user is much lower. This means that the overall outbound message throughput is generally much higher in trading applications (you can have tens of messages per second per user in trading vs. one per second or less in chats). So, the only requirement for chat-oriented Comet servers is to scale well over high numbers of TCP sockets. While Meebo started with lighthttpd, the major social sites developed their servers internally, more than using off-the-shelf products.

The live chat example above is based on another Lightstreamer demo. You can check out the full source code and explanation.

Even More Chat

The launch of Google Wave pushed real-time interaction a step further. One of the features of Google Wave that caused most hype is the character-by-character real-time dispatching of messages. Well, let me mention immodestly that here at Lightstreamer we publicly demonstrated this feature in February 2006, when my colleague Simone Fabiano came up with this idea, based on early desktop chat platforms, and implemented a demo :-) .

Above you can play with that demo, which is quite effective (what do you think?). Just type something in any of the two “broadcast” fields. Your message will be pushed in real-time as you type it to all the browsers connected to this page. For the best experience, open this page in two different browsers, or ask a colleague to visit this page in their browser as well.

You can check out more information on this demo.

Monitor Consoles

From a more general perspective, the Comet paradigm is the right solution when you need to monitor the state of any variables in real time. There exist many kinds of monitor consoles. There are consoles for monitoring software processes, hardware components, the physical environment (e.g. atmospheric or geological variables), transportation systems, etc. These consoles are often web-based and they usually provide the current snapshot for a given set of variables. Again, being able to push updates for such variables in real-time, without a manual page refresh or traditional Ajax polling techniques, will provide a dramatic improvement to the system.

Above you can see an example of a tiny monitor console, which shows some real-time variables of an actual Lightstreamer Server instance. The demo is pushing updates on: the free memory on the server, the current number of connections to the server, the current total outbound bandwidth used by the server, and the total number of bytes pushed since server’s startup.

Again, the full Lightstreamer demo from which the example above was extracted is available with source code and explanations.


I focused on three typical examples of real-time applications. Many more application domains can benefit from the Comet paradigm. The raise of the number of good Comet servers on the market, both free and commercial, is helping many application progressively transition to the Comet-driven real-time web.

Many other online examples are available from the Lightstreamer gallery, covering several different client-side technologies (including Ajax, Flex, Silverlight, .Net, Java, and iPhone). Below is the full list to date:

HTML & JavaScript

Other Ajax Frameworks

Flash, Flex, and Air



Java SE

Java ME


4 Responses to “Concrete Comet Examples”

  1. Robert Smart Says:

    Google Wave is a comet demo. They claim it uses xmpp for realtime, but there is no way for a javascript web app to receive xmpp except through some sort of comet. Does google have a plan for real time comet-like programs for google app engine? When xmpp was released for app engine there was no provision for real time access (without extra software). I made a prediction/suggestion in a comment on issue 377: . No response from Google.

  2. Olivier Says:


    I see in the status bar of that the page is always in waiting mode.

    In google finance (ex: the page seems to be “completely” loaded and not in waiting mode.

    Do you know how Google achieve this ?

    Thanks !

  3. NoHype Says:

    From what I’ve seen the utility of “Comet” is greatly overstated.

    Looking at your own console monitor above illustrates how most useful applications will have constant data updates (same with trading apps, a ticker symbol’s price changes constantly).

    So utilizing a framework designed primarily to solve corner-case problems (send updates only when the data has changed) seems more an exercise to “use the latest stuff” than striving to execute the cleanest, and simplest (KISS) solution.

  4. Alessandro Alinone Says:

    @NoHype: Sending constant data updates is exactly what Lightstreamer does, thanks to its streaming technology. Please bear in mind that the word “Comet” covers both the streaming case and the long polling case.

Copyright 2015 Comet Daily, LLC. All Rights Reserved