简体   繁体   English

什么时候应该使用自托管的SignalR,什么时候不应该使用?

[英]When we should use SignalR self hosted and when we should not?

I am in a stage of using SignalR in my project and i don't understand when to use Self hosted option and when we should not use. 我正处于在项目中使用SignalR的阶段,我不知道何时使用自我托管选项以及何时不应该使用。 As a example if I am willing to host my web application in server farm, 例如,如果我愿意将我的Web应用程序托管在服务器场中,

  • There will be separate hosting servers 将有单独的托管服务器
  • Separate SignalR hubs in each IIS server 每个IIS服务器中的单独SignalR集线器

If we want to broadcast message into each client, how this is working in SignalR 如果我们想向每个客户端广播消息,这在SignalR中是如何工作的

The idea with SignalR running in multiple instances is that clients connected on instance A cannot get messages from clients connected to instance B. 在多个实例中运行SignalR的想法是,连接到实例A的客户端无法从连接到实例B的客户端获取消息。

( SignalR scaleout documentation ) SignalR横向扩展文档

However, when you scale out, clients can get routed to different servers. 但是,向外扩展时,客户端可以路由到其他服务器。 A client that is connected to one server will not receive messages sent from another server. 连接到一台服务器的客户端将不会收到从另一台服务器发送的消息。

The solution to this is using a backplane - everytime a server recieves a message, it forwards it to all other servers. 解决方案是使用backplane -每当服务器接收到一条消息时,它将转发到所有其他服务器。 You can do this using Azure Service Bus , Redis or SQL . 您可以使用Azure Service BusRedisSQL进行此操作

The way I see, you use the self host option when you either don't want the full IIS running (because you have some lightweight operations that don't require all IIS heaviness) or you don't want a web server at all (for example you want to add real-time functionality to an already existing let's say forms application, or in any other process). 我的看法是,当您不希望完整的IIS运行(因为您进行了一些轻量级的操作不需要全部IIS重载)或根本不希望使用Web服务器时,可以使用self host选项。例如,您想将实时功能添加到已经存在的表单应用程序中,或通过任何其他过程添加)。

Be sure to read the documentation for self-hosting SignalR and decide whether you actually need to self host SignalR. 确保阅读自托管SignalR文档,并确定是否实际需要自托管SignalR。

If you are developing a web application under IIS, I don't see any reason why you would want to self-host SignalR. 如果您要在IIS下开发Web应用程序,则我看不出您为什么要自托管SignalR的任何原因。

Hope this helps. 希望这可以帮助。 Best of luck! 祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM