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:
Any help will be appreciated, thanks in advance!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With