轮询服务器状态的方法
我尝试创建一个 JSP 页面来显示一组本地服务器中的所有状态。 目前,我创建了一个调度类,它将不断轮询以 30 秒的间隔检查服务器的状态,延迟 5 秒等待每个服务器回复,并向 JSP 页面提供信息。但我发现这种方式并不准确,因为需要一些时间才能更新时间表类的信息。你们有更好的方法来检查本地网络中多个服务器的状态吗?
--更新--
感谢@Romain Hippeau和@dbyrne的回答
目前我正在尝试使代码更多地位于服务器端,即进行不断的检查 异步更新服务器组的状态,使其响应更快。 但是我忘了补充一点,客户端有能力控制服务器状态。因此,例如当客户端更改服务器状态,然后刷新页面时,我会遇到问题。当页面从未更新的调度类中检索信息时,它将显示服务器以前的状态。
I am try to create a JSP page that will show all the status in a group of local servers.
Currently I create a schedule class that will constantly poll to check the status of the server with 30 second interval, with 5 second delay to wait for each server reply, and provide the JSP page with the information. However I find this way to be not accurate as it will take some time before the information of the schedule class to be updated. Do you guys have a better way to check the status of several server within a local network?
-- Update --
Thanks @Romain Hippeau and @dbyrne for their answers
Currently I am trying to make the code more in server end, that is to do a constant check
on the status of the group of server asynchronously for update so as to make it more responsive.
However I forgot to add that the client have the ability to control the server status. Thus I have problem for example when the client changes the server status, and then refresh the page. When the page retrieve the information from not updated schedule class, it will show the previous status of the server instead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Tomcat Comet,这里有一篇文章 http://www .ibm.com/developerworks/web/library/wa-cometjava/index.html。
这项技术(Servlet 3.0 规范的一部分)允许您向客户端推送通知。在防火墙后面运行它会出现问题,如果您在内联网中,这应该不是太大的问题
You can use Tomcat Comet here is an article http://www.ibm.com/developerworks/web/library/wa-cometjava/index.html.
This technology (which is part of the Servlet 3.0 spec) allows you to push notifications to the clients. There are issues with running it behind a firewall, If you are within an Intranet this should not be too big of an issue
确保异步轮询服务器。您不想在轮询下一台服务器之前等待一台服务器的响应。这将大大减少轮询所有服务器所需的时间。从你的问题中我不清楚你是否已经在这样做了。
Make sure you poll the servers asynchronously. You don't want to wait for a response from one server before polling the next. This will dramatically cut down the amount of time it takes to poll all the servers. It was unclear to me from your question whether or not you are already doing this.