SitePen Support
Comet Support by SitePen

The Long-Polling Technique

by Dylan SchiemannNovember 15th, 2007

The long-polling Comet technique is a technique that optimizes traditional polling to reduce latency.

Traditional polling sends an XMLHttpRequest to the server in fixed intervals. For example, open a new XMLHttpRequest every 15 seconds, receive an immediate response, and close the connection.

Long-polling sends a request to the server, but a response is not returned to the client until one is available. As soon as the connection is closed, either due to a response being received by the client or if a request times out, a new connection is initiated. The result is a significant reduction in latency because the server usually has a connection established when it is ready to return information to return to the client.

Greg Wilkins recently compared long-polling to traditional polling in the article Comet is Always Better Than Polling.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Orbited

6 Responses to “The Long-Polling Technique”

  1. Simon Willison Says:

    It strikes me that long polling might not be appropriate for situations where you are broadcasting the same event to very large numbers of clients, because it will cause all of those clients to attempt to start a new HTTP request simultaneously - or are the various high performance cometd servers designed to be able to cope with thi?

  2. Comet Daily » Blog Archive » More on Long-Polling Says:

    [...] Dylan talked about the long-polling technique. This method has become fairly well-disseminated, but there are some misconceptions as to the [...]

  3. Comet Daily » Blog Archive » The Future of Comet: Part 1, Comet Today Says:

    [...] Long-polling works differently than streaming. Instead of stringing together every event in a single indefinitely long server response, our server keeps each connection open until it has an event, but then closes it after sending a response. Then the browser immediately opens another connection, ensuring that the server can pass it events in real time. This is less effective than streaming transports with respect to bandwidth overhead and throughput; it works, however, in all recent browsers—without the ugly side effects of iframe streaming. [...]

  4. Comet Daily » Blog Archive » Latency: Long Polling vs Forever Frame Says:

    [...] of the oft-cited advantages of forever frame over long polling is that it does not suffer from the 3x max latency issue. This is when an event occurs the instant [...]

  5. Hot topics for 2009 – Realtime Web « Was that my outside voice? Says:

    [...] development pattern is called Comet , and typically uses the long-polling technique. Holding connections open is better than polling – the latency is lower, and total [...]

  6. Hot topics for 2009 – Realtime Web | Tim Gregory Says:

    [...] development pattern is called Comet , and typically uses the long-polling technique. Holding connections open is better than polling – the latency is lower, and total [...]

Leave a Reply



Copyright 2014 Comet Daily, LLC. All Rights Reserved