负载平衡控制台应用程序或服务

发布于 2024-08-27 03:26:04 字数 411 浏览 4 评论 0原文

因此,对 ASP.NET Web 应用程序进行负载平衡很容易。您在两台服务器之间设置了负载平衡器,如果 Web 服务器在端口 80 上没有响应,它将不会接收请求。

是否有任何经过验证的技术可以为 C# 控制台应用程序或自行采取操作的 Windows 服务执行此操作?是否有任何框架可以了解对等进程是存活还是死亡、进行心跳等?

我一直在尝试 NServiceBus ,对于某些类型的应用程序来说,它似乎会有所帮助将大部分工作作为对事件的响应来完成,这实际上使它更像一个 Web 应用程序,因此更容易通过多个进程进行扩展和负载平衡,但我觉得这是一个不成熟的解决方案,因为在大多数情况下在这种情况下,通常需要有一些“主”流程的概念来负责开始工作。

So it's easy to load balance an ASP.NET web application. You set up a load balancer between two servers, and if the web server isn't responding on Port 80, it won't receive requests.

Are there any proven techniques for doing this for a C# console application or Windows service that takes actions of its own volition? Are there any frameworks for knowing if peer processes are alive or dead, doing heartbeats, etc?

I've been experimenting a bit with NServiceBus and it seems like, for certain kinds of applications, it would help to have most of the work done as a response to an event, which makes it more like a web application, actually, and therefore easier to scale and load balance with multiple processes, but I feel like that's a half-baked solution since in most cases there usually needs to be some concept of a "master" process that's responsible for getting work started.

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

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

发布评论

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

评论(1

自此以后,行同陌路 2024-09-03 03:26:04

NServiceBus 确实通过其 Distributor 进程为您处理了这个问题(此处描述:http: //docs.pspecial.net/nservicebus/scalability-and-ha/distributor/)。 NServiceBus 附带的通用主机允许您将完全相同的代码和配置作为控制台应用程序和 Windows 服务运行(此处描述:http://docs.pspecial.net/nservicebus/hosting/nservicebus-host/)。

您可以将其用于事件以及常规命令消息。

如果您想要一个“主”进程来决定当所有负载平衡工作完成时要做什么,这将以 saga 基础设施的形式提供给您(此处描述:http://docs.pspecial.net/nservicebus/sagas/ 并在 NServiceBus 附带的制造示例中进行了演示)。

简而言之,您应该几乎得到了保护。

NServiceBus does indeed handle this for you with its Distributor process (described here: http://docs.particular.net/nservicebus/scalability-and-ha/distributor/). The generic host that comes with NServiceBus allows you to have the exact same code and configuration run both as a console app and as a windows service (described here: http://docs.particular.net/nservicebus/hosting/nservicebus-host/).

You can have this for events as well as for regular command messages.

If you want a "master" process to decide what to do when all the load-balanced work completes, that is provided to you in the form of the saga infrastructure (described here: http://docs.particular.net/nservicebus/sagas/ and demonstrated in the Manufacturing sample that comes with NServiceBus).

In short, you should pretty much be covered.

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