I am having network issues with my Java (7) application on linux where packets are occasionally delayed.
The sysadmins have said that the listen backlog set is too low and thus is not accepting connections fast enough.
ss -lt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:1099 *:*
The default on this system is 128
sysctl -a 2>/dev/null|grep net.core.somaxconn
net.core.somaxconn = 128
Is 50 the default for RMI connections in JDK7?
How do I increase it to make it use the system default?
It looks like 50 is the default value in the JDK.
sun.rmi.transport.tcp.TCPEndpoint
calls RMIServerSocketFactory.createServerSocket(this.listenPort);
The implementations of RMIServerSocketFactory
e.g. RMIDirectSocketFactory
do
new ServerSocket(int);
As we can see from the ServerSocket javadocs: https://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#ServerSocket(int)
The maximum queue length for incoming connection indications (a request to connect) is set to 50
Therefore, one way to increase the value is to create your own implementation of RMIServerSocketFactory
and call a different ServerSocket
constructor that allows you to set your own backlog value.