如何有效地将 Web 前端连接到我的服务器应用程序?

发布于 2024-11-30 13:03:28 字数 780 浏览 5 评论 0原文

我们的服务器产品目前采用桌面形式,我们正在尝试将其转移到服务中,同时提供基于 Web 的前端,以使其更易于监控和管理。由于没有大量的网络经验,我正在努力寻找最好的方法来做到这一点。

对于第一次通过,我们的要求非常基本。我们希望能够查看系统各个组件的状态并实时监控它吐出的日志。

我的想法是向我们的服务器应用程序添加某种基于 TCP 的接口,该接口可供运行在不同服务器上的单独 Web 框架使用。对于基本状态消息,这似乎很简单:用户连接到 Web 界面,它向服务器应用程序查询当前状态,然后向用户显示该状态。当涉及到日志流时,情况会变得更加复杂。我担心不断地从服务器应用程序请求最新日志,特别是如果每​​个用户都有单独的连接,会给服务器应用程序带来比我们希望的更大的压力。

理想情况下,Web 服务器似乎会打开与服务器应用程序的单个持久连接,并且服务器应用程序会在状态更改或记录新消息时将数据推送到 Web 服务器。然后,网络服务器将缓存该数据并将其“转发”给所有连接的用户。这样,服务器应用程序正在执行的工作量很大程度上是固定的,并且不依赖于当前连接到服务器的用户数量。

我的问题是:

  1. 这从根本上讲有意义吗?
  2. 我该怎么做呢?这是 Web 框架应该能够处理的事情(我倾向于提升,但现在不与任何东西绑定),还是我需要编写自己的中间缓存层来保持与服务器应用程序的持久连接,但是根据需要将数据提供给网络服务器?我最好的选择是从头开始做这件事,还是已经有针对此类事情经过充分测试的解决方案?

正如我所提到的,当涉及到任何类型的 Web 开发时,我都是一个相当菜鸟,因此任何即使只是为我指明正确方向的事情都会有所帮助。

Our server product is currently in desktop form and we're trying to move it over to a service while providing a web-based frontend to make it easier to monitor and administrate. Not having a ton of web experience I'm struggling with figuring out the best way to do this.

For a first pass, our requirements are pretty basic. We want to be able to view the status of the various components of our system and real-time monitor the logs that it spits out.

My thought is to add some sort of TCP-based interface to our server application that can be used by a separate web framework running on a different server somewhere. For basic status messages this seems straightforward: the user connects to the web interface, it queries the server application for the current status, then displays that status to the user. It gets a bit more complicated when it comes to the log streaming. I'm concerned that constantly requesting the latest logs from the server application, especially if there is a separate connection for each user, will put more stress on the server application than we would like.

It seems that ideally the web server will open a single persistent connection to the server application, and the server application will push data to the web server anytime the status changes or a new message is logged. The web server will then cache this data and "forward" it to all connected users. This way the amount of work that the server application is doing is largely fixed and is not dependent on the number of users currently connected to the server.

My questions are:

  1. Does this fundamentally make sense?
  2. How should I go about doing this? Is it something that a web framework should be able to handle (I'm leaning towards lift, but not tied to anything right now) or will I need to write my own intermediate caching layer that keeps a persistent connection to the server application, but serves the data to the web server as needed? Is my best bet to do this from scratch or are there already well tested solutions for this type of thing?

As I mentioned I'm a pretty big noob when it comes to any sort of web development so anything that even just points me in the right direction will help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧情勿念 2024-12-07 13:03:28

您的产品是一种将信息发送到系统日志之类的硬件设备,还是一种监视信息并具有实时日志显示并将该信息存储在文本日志文件中的软件应用程序?您没有提到有关从数据库中提取数据的任何事情,所以我假设它没有将其存储在数据库中?

我不确定我是否完全理解了这个难题,但考虑到这一点,我想到了一些想法...

  • 让您的服务器应用程序将日志数据存储在 Web 服务器可以访问的数据库中,然后使用支持 AJAX 的 Web 前端每 x 秒刷新网页的“日志视图”部分,查找日志中的新条目以附加到视图

  • XMPP/Jabber 也可以在您的工作中发挥作用正在做的事情 - 该协议在某些 IM 客户端中用于实时消息传递。听起来有点像您希望它以“推送消息”的方式工作。因此,在 Web 服务器旁边设置一个 jabber 服务器(可能是同一台服务器,具体取决于负载)可能是有意义的,然后在服务器应用程序中通过 XMPP 将消息发送到 jabber 服务器,这将转发它们对于听众来说,这将是 XMPP/Jabber 客户端 - 我知道 googletalk 可以充当客户端,iChat 可以,而且我相信其他一些客户端。或者你可以编写一个 Java 客户端在浏览器中运行(不过我不是 Java 人......)
    然后编写一个最小的 Web 应用程序来处理应用程序的管理方面的事情。
    您或许还可以通过 XMPP 处理管理方面的事务 - 向其发送一条消息以“将 x 设置更改为 y”,并且可能仅在一台服务器上完成所有操作,而无需单独的 Web/jabber 服务器。

但这些是我会关注的事情。

我相信 www.jivesoftware.org 仍然有免费的 jabber 服务器,而且我与他们没有任何关系 - 只是我曾经尝试过的东西,并认为它非常有趣。

格雷格

Is your product a hardware device that puts out info to something like a syslog, or a software app that monitors the info, and has a real-time log display and stores that info in text log files? You didn't mention anything about pulling the data from a database, so I'm assuming it's not storing it in one?

I'm not sure I understand completely the pieces of the puzzle, but with that in mind, a couple thoughts come to mind...

  • Have your server app store that log data in a db somewhere that the web server can access, then use an AJAX-enabled web frontend to refresh the 'log view' section of the web page every x seconds looking for just new entries to the log to append to the view

  • XMPP/Jabber might also be able to play a part in what you're doing - the protocol is used in some IM clients for real-time messaging. It sounds a bit like you're wanting this to work in a 'push messaging' kind of way. So, possibly it could make sense to setup a jabber server alongside the web server (could probably be the same server, depending on load), and then in your server app send the messages to the jabber server via XMPP, which will relay them out to the listeners, which would be XMPP/Jabber clients - I know googletalk can act as a client, and iChat can, and I believe some others. Or you can possibly write a Java client to run in the browser (I'm not a Java person, though...)
    And then write a minimal web app to handle the administration side of things for the app.
    You could probably also handle the administration side of things over XMPP - send it a message to 'change x setting to y' and possibly do it all on just the one server without a need for a separate web/jabber server.

But these are things I'd look at.

www.jivesoftware.org still has their jabber server available free I believe, and I have no association with them - just something I experimented with at one time and thought it was very interesting.

Greg

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文