What is Comet?

23 Sep
Comet is a generic term describing various approaches to send data asynchronously from a Web server to a client without the need for the client to explicitly request the data. It is an essential technique for any real-time event-driven web applications, where the majority of events occur on the server and data must be “pushed” frequently to the client.

Financial trading applications are a good example of this; pricing updates occur frequently and must be relayed to the client at a high rate, whereas user generated events such as buying and selling happen less often. Comet is also known as server push, HTTP push, or HTTP streaming.

How does it work?

Comet applications use long-lived HTTP or HTTPS connections between the client and server, through which the server can push new data to the client as it becomes available. Unlike traditional Web servers, which deliver a single payload and then immediately close the connection to the client, Comet servers must maintain a continuous connection to each client for the duration of the session. Adapting a traditional server to the Comet methodology may not scale and often fails after a few thousand simultaneously open connections. A true Comet implementation requires a very different kind of server architecture to be efficient and scalable.

How does Comet differ from traditional data transfer and Ajax?

In the original request-response model of the Web, a browser receives a complete Web page in response to each request.

Ajax was invented to overcome this overhead by doing away with the need to receive a new page and instead simply request a data response from the server. However, Ajax is still a request-response model, and since Ajax requires that the client initiates each interaction, data cannot be sent at will from the server. To get round this problem, Ajax applications often use polling to detect new information on the server, but this often results in unacceptable loads on the server and client.

Comet is a ‘push’ approach, greatly improving throughput and decreasing latency and server load. Once the client has made the initial connection, the server sends updates as they occur, without the client needing to issue further requests. See the figure above for a comparison of Ajax and Comet data transfer.

Leave a comment

Posted by on September 23, 2008 in COMET


Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: