彗星VS阿贾克斯投票 [英] Comet VS Ajax polling
问题描述
我需要创建像Facebook聊天聊天。
I need to create a chat like facebook chat.
随着彗星我需要更多的内存来保持连接。
With Comet I need more memory to keep the connection.
使用Ajax轮询存在延迟问题,如果我发送的请求,每3-4秒。
With Ajax polling there is a latency problem if I send request every 3-4 seconds.
所以......如果等待时间(3-4秒)不要紧,是Ajax轮询更适合我的情况?
So... If the latency ( 3-4 seconds ) doesn't matter, Is Ajax Polling better for my case ?
推荐答案
延迟是不是唯一的问题。 COMET(长轮询)拯救你的流量 - 当你使用查询,你可以不知道,是否有在服务器上进行更改,所以一些电话可能只是浪费流量和资源(例如,即使没有人聊天,你拨打电话,每3-4秒)。如果彗星,通常需要ONE仅有调用从服务器获取更新(以100%的命中率)。
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).
这篇关于彗星VS阿贾克斯投票的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!