简体   繁体   English

HTML5 websockets:最大打开连接数?

[英]HTML5 websockets: max number of open connections?

HTML5 websockets are (and have been for some time ) a hot topic as they elegantly enable real-time server-side push . HTML5 websockets是(并且已经有一段时间 )一个热门话题,因为它们优雅地实现了实时 服务器端推送

I currently have a working application with websockets powered by Tomcat 7.0.30 which includes websocket support . 我目前有一个工作应用程序,其中包含由Tomcat 7.0.30 提供支持的websockets ,其中包括websocket支持 But moving this to a production environment raises questions. 但是将其转移到生产环境会引发问题。

Mainly I would like to know the possible maximum number of connections that can operate (be open ) concurrently per browsing session ; 主要是我想知道每个浏览会话可以同时操作( 打开 )的最大连接数; a browsing session implies a single browser tab or window. 浏览会话意味着单个浏览器选项卡或窗口。

Do open websocket connections add up to the maximum number of connections that can be processed simultaneously by the Web server? 开放的websocket连接是否与Web服务器可以同时处理的最大连接数相加? Eg MaxClients in Apache. 例如Apache中的MaxClients

Conversely, is the maximum number of websockets for a single browsing session limited by the browser itself? 相反, 浏览器本身限制的单个浏览会话的最大websockets数是多少? As this blog post shows, up to April 2012, different browsers support varying amounts of open websocket connections. 正如此博客文章所示,截至2012年4月,不同的浏览器支持不同数量的开放 websocket连接。 (I personally would aim for 1 open websocket per browsing session ; but this info would still be good to know). (我个人的目标是每个浏览会话 1个开放的websocket;但是这个信息仍然很好知道)。

TL/DR: TL / DR:

  1. What limits the amount of possible websockets per browsing session ? 是什么限制了每次浏览会话可能的websockets数量? Is it the client? 是客户吗? The server? 服务器? Or a combination of both? 或两者兼而有之?
  2. Does the same limitation(s) apply to both ws: and wss: connections? 同样的限制是否适用于ws:wss: connections?

There isn't a standard specification of max-connections default value for browsers.It depends on implementation [0]. 浏览器没有最大连接默认值的标准规范。它取决于实现[0]。 Furthermore using more than a web-socket per browsing session for the same application seems overkill since you can use pub/sub channels. 此外,对于同一应用程序而言,每次浏览会话使用多个Web套接字似乎有些过分,因为您可以使用发布/订阅源渠道。

Bottleneck for connections usually is at server side. 连接的瓶颈通常是在服务器端。 Web-socket is a upgrade to HTTP so connections are "just" upgraded HTTP(TCP) connections [1].HTTPS and WSS add just a security layer to the normal connection.They are not a different connection [2]. Web套接字是对HTTP的升级,因此连接只是“升级”HTTP(TCP)连接[1] .HTTPS和WSS只为正常连接添加了一个安全层。它们不是一个不同的连接[2]。 In your case check maxConnections (and maxThreads ) [3] and your Operating System maximums [4][5]. 在您的情况下,检查maxConnections (和maxThreads )[3]和您的操作系统最大值[4] [5]。 If your concurrent connections reach tens of thousands maybe you should start thinking on load balancing or clustering [6]. 如果您的并发连接数达到数万,那么您应该开始考虑负载平衡或群集[6]。

[0] https://code.google.com/p/chromium/issues/detail?id=85323 [0] https://code.google.com/p/chromium/issues/detail?id=85323

[1] http://en.wikipedia.org/wiki/WebSocket [1] http://en.wikipedia.org/wiki/WebSocket

[2] http://en.wikipedia.org/wiki/HTTP_Secure [2] http://en.wikipedia.org/wiki/HTTP_Secure

[3] http://tomcat.apache.org/tomcat-7.0-doc/config/http.html [3] http://tomcat.apache.org/tomcat-7.0-doc/config/http.html

[4] https://serverfault.com/questions/10852/what-limits-the-maximum-number-of-connections-on-a-linux-server [4] https://serverfault.com/questions/10852/what-limits-the-maximum-number-of-connections-on-a-linux-server

[5] https://superuser.com/questions/251596/is-there-a-hard-limit-of-65536-open-tcp-connections-per-ip-address-on-linux [5] https://superuser.com/questions/251596/is-there-a-hard-limit-of-65536-open-tcp-connections-per-ip-address-on-linux

[6] http://tomcat.apache.org/tomcat-7.0-doc/config/cluster.html [6] http://tomcat.apache.org/tomcat-7.0-doc/config/cluster.html

More about high concurrency: http://www.kegel.com/c10k.html 有关高并发性的更多信息: http//www.kegel.com/c10k.html

In Gecko 7 they introduced the aprameter network.websocket.max-connections you can set it in about:config . 在Gecko 7中,他们引入了参数network.websocket.max-connections你可以在about:config设置它。 It's setting the maximum websocket connections "at a time" according to this: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API 它根据这个来“一次”设置最大的websocket连接: https//developer.mozilla.org/en-US/docs/Web/API/WebSockets_API

I don't know if you can determine this number from the code and if there is any way to determin how many is open in other sessions (so how many you have left). 我不知道你是否可以从代码中确定这个数字,以及是否有办法确定在其他会话中打开了多少(所以你剩下多少)。

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

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