SignalR 作为自包含应用程序或作为 Web 应用程序的一部分托管

SignalR hosted as a self contained application or as a part of a web application

我一直在阅读有关 SignalR API 的内容并尝试实施相同的内容。我创建了一个 MVC Web 应用程序,它是 SignalR Hub 的客户端。客户端是 JavaScript 客户端。我创建了 SignalR Hub 作为同一应用程序的一部分。我了解到 SignalR 也可以作为独立应用程序自行托管。我的困惑是,如果我将它从我的 Web 应用程序中分离出来并单独托管,会有什么不同吗?这两种方法是否各有利弊。

如何组织项目取决于您。我觉得有几点很有意思: https://docs.microsoft.com/en-us/aspnet/signalr/overview/deployment/tutorial-signalr-self-host:

Reasons for not hosting in IIS include:

  • Environments where IIS is not available or desirable, such as an existing server farm without IIS.
  • The performance overhead of IIS needs to be avoided.
  • SignalR functionality is to be added to an exising application that runs in a Windows Service, Azure worker role, or other process.

If a solution is being developed as self-host for performance reasons, it's recommended to also test the application hosted in IIS to determine the performance benefit.