Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comet VS Ajax polling

I need to create a chat like facebook chat.

With Comet I need more memory to keep the connection.

With Ajax polling there is a latency problem if I send request every 3-4 seconds.

So... If the latency ( 3-4 seconds ) doesn't matter, Is Ajax Polling better for my case ?

like image 206
xRobot Avatar asked Jun 04 '10 14:06

xRobot


3 Answers

Latency is not the only problem. COMET (long-polling) "saves" your traffic - when you use polling, you cannot know, if there were changes on the server, so some of the calls may be just a waste of traffic and resources (e.g., even if no one's chatting, you're making calls every 3-4 seconds). In case of COMET, you generally need one just call to get an update from the server (with 100% hit rate).

like image 163
Vasil Remeniuk Avatar answered Nov 20 '22 16:11

Vasil Remeniuk


@Vasil: "you can keep millions of opened connection"

Take a look to this problem

And regarding the false superiority of NIO over IO.

The iobound article just shows IO outperforms NIO and yes IO goes out of memory before NIO (by the way, the author has not tried to reduce the stack memory with a lower value).

like image 27
jmarranz Avatar answered Nov 20 '22 15:11

jmarranz


If latency isn't an issue then AJAX is probably better. Comet can encounter problems maintaining multiple connections between the same client/server pair if you're not very, very careful. (Ref)

like image 42
Quotidian Avatar answered Nov 20 '22 15:11

Quotidian