客户端通知,我应该使用AJAX推送或轮询? [英] Client notification, should I use an AJAX Push or Poll?

查看:100
本文介绍了客户端通知,我应该使用AJAX推送或轮询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,这将被用来传递消息给用户浏览一个网站,一个简单的通知服务。该通知没有实时发送,但它可能是一个更好的用户体验,如果他们发生的频率比说,每5分钟。该数据被发送到和从客户端不是非常大,这是一个简单的数据库查询来检索数据。

I am working on a simple notification service that will be used to deliver messages to the users surfing a website. The notifications do not have to be sent in real time but it might be a better user experience if they happened more frequently than say every 5 minutes. The data being sent to and from the client is not very large and it is a straight forward database query to retrieve the data.

在阅读问题的其他谈话它会出现一个AJAX推可能会导致更高的服务器负载。因为我可以容忍更长的服务器延迟是值得让服务器推送通知,或简单地调查。

In reading other conversations on the topic it would appear that an AJAX push can result in higher server loads. Since I can tolerate longer server delays is it worth while to have the server push notifications or to simply poll.

这不是很难实现推送的场景,所以我想我会看的意见在这里的东西。

It is not much harder to implement the push scenario and so I thought I would see what the opinion was here.

感谢您的帮助。

编辑: 我看过一个简单的AJAX推送,并实现了一个简单的演示基于此文章通过迈克·珀维斯。 该客户端负载是相当低的,在5K左右的最初版本,并有望持续这种状态相当长的一段时间。

I have looked into a simple AJAX Push and implemented a simple demo based on this article by Mike Purvis. The client load is fairly low at around 5k for the initial version and expected to stay that way for quite some time.

感谢大家对你的反应。我决定去与轮询解决方案,但要在一个实用程序库包装这一切使,如果他们想要在以后改变它很容易。

Thank you everyone for your responses. I have decided to go with the polling solution but to wrap it all within a utility library so that if they want to change it later it is easier.

推荐答案

由于使用推,需要一个开放的HTTP连接,以保持你的服务器和每个客户机之间,我会去投票,以及 - 不仅是去要消耗大量的服务器资源,但它也将是显著更棘手的实施,因为亚光B中提及。

Because using a push requires an open HTTP connection to be maintained between your server and each client, I'd go for poll as well - not only is that going to consume a lot of server resources but it's also going to be significantly more tricky to implement as matt b mentioned.

我有投票的经验是,如果你有一个够忙的网站足够频繁的轮询间隔网络服务器日志可以得到与轮询请求真正迅速淹没了。

My experience with polling is that if you have a frequent enough polling interval on a busy enough site your web server logs can get flooded with poll requests real quickly.

这篇关于客户端通知,我应该使用AJAX推送或轮询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆