SignalR/Websockets 连接限制和最佳实践 [英] SignalR / Websockets connection limitations and best practices

查看:54
本文介绍了SignalR/Websockets 连接限制和最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to understand how to best design an IIS/ASP.NET based websocket application, specifically regarding concurrency limitations.

我已经阅读了关于 IIS/ASP.NET 的所有关于并发 Websocket 连接"以及如何调整各种值的文献 - 但是,当谈到 websockets 时,并发"的定义是什么?如果我打开了一个 websocket 并且它闲置,那是使用"连接吗?空闲的 websocket 是否计入连接使用总量,还是仅在发送/接收消息时计入?

I've read all the literature on IIS/ASP.NET regarding "concurrent Websocket connections" and how to tweak the various values - 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?

我希望在任何时候都会有非常多(成百上千)的 websocket 打开,但是发送的消息很少,可能每分钟有几条,而且它们将始终是服务器-> 客户端(并且到单个特定客户端,而不是广播).这种安排是否/应该让我走上任何特定的实施路线?

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 集线器可能有点矫枉过正,我不需要为不支持 websockets 的客户端回退,我只需要维护每个客户端连接的句柄,这样当我的系统决定"向一个特定的客户端,它可以适当地路由它.

It seems SignalR hubs are probably overkill, I don't need fallbacks for clients that dont support websockets and I only need to maintain a handle on the each clients connection, such that when my system "decides" to send a message to a particular client, it can route it appropriately.

我参考的文档:

谢谢

推荐答案

然而,在谈到 websockets 时,它的定义是什么同时"?如果我打开了一个 websocket 并且它闲置,是那个使用"一个连接?空闲的 websockets 是否计入连接使用总量,还是仅在发送消息时计算发送/接收?

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 保持连接之外的太多资源,如果您的服务器支持它们,可能还会消耗协议和/或应用程序级别的 ping/pongs.更重要的是,由于 Websocket 是面向连接的,您可能还持有一些与连接相关的状态(用户对象、用户数据等...)

Right, a open connection sitting idle does not consume much resources beyond TCP keep-alives and maybe protocol and/or application level ping/pongs if your server supports them. More importantly, as Websockets are connection oriented you may be holding some state associated with the connection as well (an user object, user data, etc...)

我希望有非常多(上千个)的 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(检查限制部分).直接使用 WebSockets 并使用允许智能路由的框架(例如 RabbitMQ)实现您自己的消息传递后端.您不想使用基本上对所有节点进行扇出"的背板,尤其是在数据是每个用户的情况下.

Yes, to the route of not using 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 for example. You don´t want to use a backplane that is basically doing "fan-out" to all nodes, especially if the data is per user.

SignalR 是一个 polyfill,一个临时框架,直到 WebSockets 被广泛支持的那一天...... 而且这已经发生了.还忘了提到 WebSockets 从 Windows Server 2012 开始可用:)

SignalR is a polyfill, a transient framework until the day WebSockets are broadly supported... and that already happened. Also forgot to mention that WebSockets are available from Windows server 2012 onwards :)

这篇关于SignalR/Websockets 连接限制和最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆