网络服务调度程序
这是我的问题:我有一个由 Qt GUI 和大量后端代码组成的 C++ 应用程序。目前它被链接到一个可执行文件并在 Solaris 上运行。现在,我想在 Windows 上运行 GUI,并让其余代码在 Solaris 上运行(移植它将是一项巨大的工作)。 GUI 和后端之间的接口非常干净,由一个 C++ 抽象类组成(还使用一些 stl 容器)。这是我想变成网络服务的部分。
问题是我们的后端代码不是线程安全的,因此我需要在 Solaris 上为 Windows 上的每个 GUI 运行一个单独的进程。但是,出于性能原因,我无法启动和完成来自 GUI 的每个请求的流程。
这种设计意味着我需要处理几个问题:
- GUI 代码必须有一个单一的联系点,
- 通信必须与第一次调用期间启动的实例进行(它应该被路由,或者第一次调用应该返回地址)实际服务器实例的),
- 必须在 GUI 和服务器进程之间发送一些保持活动消息来管理服务器进程的生命周期(服务器进程不能永远运行)。
您能否推荐一个能够处理这些细节(消息路由/调度和生命周期管理)的框架?
Here is my problem: I have a C++ application that consists of Qt GUI and quite a lot of backend code. Currently it is linked into one executable and runs on Solaris. Now, I would like to run the GUI on Windows and leave the rest of the code running on Solaris (porting it will be a huge effort). The interface between GUI and backend is pretty clean and consists of one C++ abstract class (also uses some stl containers). This is the part I would like to turn into webservice.
The problem is that our backend code is not thread safe therefore I will need to run a separate process on Solaris for every GUI on Windows. However, for performance reasons I cannot start and finish process for every request from the GUI.
This design means that I need to take care of several problems:
- there must be a single point of contact for the GUI code,
- the communication must happen with the instance started during first call (it should either be routed or the first call should return address of the actual server instance),
- there must be some keep-alive messages sent between GUI and server process to manage lifetime of server process (server process cannot run forever).
Could you recommend a framework that would take care of these details (message routing/dispatching and lifetime management)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从技术上配置 Apache httpd 来为每个连接生成一个新实例。该配置还允许您管理进程在空闲时保持活动状态的时间,以及至少有多少进程保持运行。只要 Web 服务是无状态的,这种方法就可以很好地工作。有点奇怪,但技术上可行。
如果您使用 gSoap 之类的东西,您可以将 Solaris 中的 C++ 类直接编译为 gSoap mod,而不必将其适应任何前端(如 PHP 或 Java)。它只需插入 Apache httpd 即可开始工作。
编辑:
我只是想到了这一点,您也可以使用 HTTP 1.1 keep-alives 来管理进程的生命周期。 Apache 允许您配置允许保持活动状态保持打开状态的时间,从而使连接的线程/进程保持活动状态。
You could technically configure Apache httpd to spawn a new instance per connection. The configuration also allows you to manage the time the processes stay alive when idle, and how many processes to leave running at a minimum. This would work well as long as the web service is stateless. A little weird, but technically feasible.
If you use something like gSoap, you can compile your C++ classes in Solaris directly into a gSoap mod and won't have to adapt it to any front-end like PHP or Java. It'll just plug into Apache httpd and start working.
Edit:
I just thought about it, and you could probably use HTTP 1.1 keep-alives to manage the life of the process too. Apache lets you configure how long it will allow the keep-alive to remain open, which keeps the thread/process for the connection active.