还有其他使这个应用程序尽可能低带宽的提示或可能的替代实现吗?
Reverse Ajax refers to an Ajax design pattern that uses long-lived HTTP connections to enable low-latency communication between a web server and a browser. Basically it is a way of sending data from client to server and a mechanism for pushing server data back to the browser.1
This server–client communication takes one of two forms:
* Client polling, the client repetitively queries (polls) the
server and waits for an answer. * Server pushing, a connection between a server and client is kept open, the server sends data when available.
Reverse Ajax describes the implementation of either of these models, or a combination of both. The design pattern is also known as Ajax Push, Full Duplex Ajax and Streaming Ajax.
并且
Request.Comet是一个简单的javascript类,可以轻松创建跨浏览器的Comet(反向Ajax)应用程序。它提供了客户端和服务器之间的实时数据传输,并可与任何服务器端语言一起使用。
我写了一个几乎完全相同的应用,以便在各种雇主使用严格的网络过滤时方便工作中的朋友们进行通信。
我发现这些轮询请求传输的数据量极小,很少超过每个已登录用户1kb/s,通常要少得多,因为你只轮询每5秒一次。
带宽真的是一个问题吗,还是你提前进行了优化?
如果你决定不采用COMET方法,那么我会和你做一样的事情,除非队列包含多条消息,然后它们一次性发送。这样你每5秒只轮询一次,没有多余(也没有少)。当然,与100个连接的人相连,这仍然导致每秒20个请求,因此您应该尝试优化服务器端,以使每个请求使用尽可能少的服务器资源(CPU / RAM / time)。在这里缓存是你的朋友。
我不会担心带宽,因为聊天消息通常都很短,而且你的请求也很小。
http://cometdaily.com/2008/10/30/comet-apps-will-not-scale-equally/