HTML5 websockets: max number of open connections?

41,351

Solution 1

There isn't a standard specification of max-connections default value for browsers.It depends on implementation [0]. Furthermore using more than a web-socket per browsing session for the same application seems overkill since you can use pub/sub channels.

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]. In your case check maxConnections (and maxThreads) [3] and your Operating System maximums [4][5]. If your concurrent connections reach tens of thousands maybe you should start thinking on load balancing or clustering [6].

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

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

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

[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

[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

More about high concurrency: http://www.kegel.com/c10k.html

Solution 2

In Gecko 7 they introduced the aprameter network.websocket.max-connections you can set it in 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

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).

Share:
41,351
Joseph Victor Zammit
Author by

Joseph Victor Zammit

Web aficionado.

Updated on September 01, 2020

Comments

  • Joseph Victor Zammit
    Joseph Victor Zammit almost 4 years

    HTML5 websockets are (and have been for some time) a hot topic as they elegantly enable real-time server-side push.

    I currently have a working application with websockets powered by Tomcat 7.0.30 which includes websocket support. 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? E.g. MaxClients in Apache.

    Conversely, is the maximum number of websockets for a single browsing session limited by the browser itself? As this blog post shows, up to April 2012, different browsers support varying amounts of open websocket connections. (I personally would aim for 1 open websocket per browsing session; but this info would still be good to know).

    TL/DR:

    1. What limits the amount of possible websockets per browsing session? Is it the client? The server? Or a combination of both?
    2. Does the same limitation(s) apply to both ws: and wss: connections?