SignalR/Websockets 连接限制和最佳实践

SignalR / Websockets connection limitations and best practices

我正在尝试了解如何最好地设计基于 IIS/ASP.NET 的 websocket 应用程序,特别是关于并发限制。

我已经阅读了关于 IIS/ASP.NET 的所有关于 "concurrent Websocket connections" 以及如何调整各种值的文献 - 但是,在谈到 websockets 时,[=31= 的定义是什么]? 如果我打开了一个 websocket 并且它处于空闲状态,那么 "using" 是一个连接吗?空闲的 websockets 是否计入连接使用总数,还是仅在消息被发送时才计入 sent/received?

我预计任何时候打开的 websocket 数量非常多(成千上万),但是发送的消息很少,可能每分钟几条,并且它们始终是服务器-> 客户端(并针对单个特定客户端,而不是广播)。 Does/should 这种安排让我走上了任何特定的实施路线?

似乎 SignalR 集线器可能有点矫枉过正,我不需要为不支持 websockets 的客户端提供回退,我只需要维护每个客户端连接的句柄,这样当我的系统 "decides" 到向特定客户端发送消息,它可以适当地路由它。

我引用的文档:

谢谢

however, when speaking about websockets, what is the definition of "concurrent"? If I have opened a websocket and its sitting idle, is that "using" a connection? Do idle websockets count towards connection usage totals, or does it only count when a message is being sent/received?

是的,一个空闲的开放连接不会消耗太多资源,除了 TCP 保持活动和协议 and/or 应用程序级别 ping/pongs 如果您的服务器支持它们。更重要的是,由于 Websockets 是面向连接的,您可能还持有与连接相关的一些状态(用户对象、用户数据等...)

I expect to have a very high (100s of thousands) number of websockets open at any one time, however there will be very few messages sent, perhaps a few per minute and they will always be server->client (and to a single, specific client, not a broadcast). Does/should this arrangement lead me down any particular implementation route?

对,以不使用SignalR的路线为例:SignalR Scale-out (check the limitations section). Use WebSockets directly and implement your own messaging back-end with a framework that allows smart routing like RabbitMQ。您不想使用基本上对所有节点执行 "fan-out" 的背板,尤其是当数据是每个用户时。

SignalR 是一个 polyfill,一个临时框架,直到 WebSockets 得到广泛支持...... and that already happened。还忘了提及 Windows server 2012 之后的 WebSockets :)