开发者

What is the proper refresh rate for an AJAX chat?

开发者 https://www.devze.com 2022-12-24 16:43 出处:网络
What is the proper refres开发者_如何学编程h rate to balance quality and not crashing the server?Don\'t poll for new messages (any refresh rate will become unaffordable when scaling), just make the ser

What is the proper refres开发者_如何学编程h rate to balance quality and not crashing the server?


Don't poll for new messages (any refresh rate will become unaffordable when scaling), just make the server push new messages to the AJAX client.

Have a look at Comet (long held http request)


This depends on a large range of factors, e.g. response time, server size, expected capacity, bandwidth. I'd say once every 500ms on completion of a request would feel comfortable.

Make sure to start the timer after the last request completed, otherwise they'll queue up and overlap due to latency.

I'd suggest when doing this, pass a datetime back and forth, push the time of the last message to the client when sending, and when requesting send that time back to the server, so you're only returning messages after that time, the minimum amount of chat data.

0

精彩评论

暂无评论...
验证码 换一张
取 消