What's the maximum count of active websocket connections supported by tomcat 7.0

tomcat, websocket

Solution

TO reach the max alive websocket connections in Tomcat, the following config changes need to be done.

`{CATALINA_HOME}/conf/server.xml`

<Connector connectionTimeout="-1" port="8080" 
       protocol="org.apache.coyote.http11.Http11NioProtocol" 
       redirectPort="8443" maxConnections="100000" acceptCount="300"/>

Check the number of ports which are available for use on the machiine where Tomcat is deployed:

$ cat /proc/sys/net/ipv4/ip_local_port_range

Change this from 50 to 65535.

$ sysctl -w net.ipv4.ip_local_port_range="500   65535"

The above configuration changes allow around ~50k live connections in a 2GB Intel Core i5 machine provided the server and client are running on different machines.

Problem

I'm developing a game server currently, to avoid developing the server from scratch, tomcat 7.0 is employed so that I can focus on the game logic. Base on the requirement, I use websocket to communicate with the clients, but when many clients have connected to the server, new connection can't be established, I doubt the count of established connections has reached the maximum count. By the way, APR connector is used by tomcat. So, my questions are: - What's the maximum count of active websocket connections supported by tomcat 7.0. - How to configure it. - Is there any solution to load balancing of websocket, because apache and mod_jk can't be used for load balancing now. Any help will be appreciated, thanks in advance!

Original source

Related problems