实施实时网络仪表板
我想实现一个仪表板,它基于网络并且具有各种指标,其中一个指标每分钟更改一次,其他指标每天更改两次。如果发生更改,应尽快通过 AJAX 更新指标。这意味着同一页面将运行至少几个小时。
在 Java 世界中处理这个问题最有效的方法(技术/实现方面)是什么?
I'd like to implement a dashboard that is web-based and has a variety of metrics where one changes every minute and others change like twice a day. Via AJAX the metrics should be updated as quick as possible if a change occured. This means the same page would be running for at least several hours.
What would be the most efficient way (technology-/implementation-wise) of dealing with this in the Java world?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,这里有两个明显的选择:
最佳解决方案取决于您拥有多少用户。如果只有几个客户端,您可能很想采用“每 5 秒轮询一次”的方法 - 甚至可能每个请求一个线程进行长轮询(尽管这可能是实施起来稍微困难一些)。如果您有很多客户端,我肯定会选择长轮询,但是您需要了解如何在特定服务器环境中将线程与连接分离。
Well, there are two obvious options here:
The best solution will depend on how many users you've got. If there are only going to be a few clients, you may well want to go for the "poll every 5 seconds" approach - or even possibly long polling with a thread per request (although that will probably be slightly harder to implement). If you've got a lot of clients I'd definitely go with long polling, but you'll need to look at how to detach the thread from the connection in your particular server environment.
我想彗星时代已经过去了。全新的 Socket.IO 协议越来越受欢迎。我建议使用 netty-socketio,它支持长轮询和 websocket 协议。 javascript,ios、android 客户端库也可用。
I think time of Comet has gone. The brand new Socket.IO protocol gaining popularity. And i suggest to use netty-socketio, it supports both long-polling and websocket protocols. javascript, ios, android client libs also available.