views:

572

answers:

2

I've been wondering if there is a real advantage to using COMET / push-technologies over the much simpler polling with long requests where the server will wait a certain maximum time for new events to happen before telling the clients that nothing happened.

Both technologies have similar client latencies and while common wisdom is that long requests are worse because they need to establish a new connection, there's also the fact that there is HTTP keep-alive -- so in the end, both seem to produce a very similar amount of traffic / load.

So is there some clear advantage to using COMET?

A: 

Some advantages I can think of:

  • Makes client programming easier.
  • Minimum latency between the real event and the notification reaching the client. With polling this has a mean time of [POLL TIME]/2 and a worst case of [POLL TIME].
  • Can minimize the resources needed in the server. See this article for example. New server technologies need to be used for this to happen.
kgiannakakis
The latency you describe is what you have with "short requests" with long requests, the server delays the answer until an event is present or a maximum timeout is reached (to prevent connection timeouts). This means you have to make like one request per minute or so but still have almost no latency as the event on the server triggers the next response.The client is not so complicated.. the client requests a single event URI and re-requests it as soon as it gets an answer.
fforw
+5  A: 

AFAIK polling with long requests pretty much IS comet. Polling with short requests is not.

mcintyre321
Bingo. The difference is holding open the requests for a long period of time, which is tricky to do efficiently on the server. If you have that, you essentially have comet.
jvenema