Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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:

  1. What's the maximum count of active websocket connections supported by tomcat 7.0.
  2. How to configure it.
  3. 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!

like image 559
Alanmars Avatar asked May 19 '14 11:05

Alanmars


1 Answers

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

  1. {CATALINA_HOME}/conf/server.xml

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

like image 170
Arijeet Saha Avatar answered Sep 23 '22 04:09

Arijeet Saha