SO_REUSEPORT feature support in JDK 9 for socket communication

Viswanathan, Sandhya sandhya.viswanathan at
Thu Oct 22 01:08:49 UTC 2015

This is a proposal for adding SO_REUSEPORT support in JDK 9 for socket communication. The feature is supported since Linux Kernel 3.9 in OS. It is also supported in some of BSD flavors. It removes 1:1 assignment between listen socket and IP:PORT pair and enables multiple sockets listening to the same address. This improves the scalability and parallelism of network traffic handling. For more details, please refer to

The proposal is to add the SO_REUSEPORT feature on similar lines as SO_REUSEADDR which was included in JDK7.
Add the following two API methods to java/net/ and java/net/

public void setReusePort(boolean on)

                     throws SocketException

Enable/disable the SO_REUSEPORT socket option.

               Enabling SO_REUSEPORT prior to binding the socket using bind(SocketAddress) allows the socket and all the sockets created after this socket being able to listen to

               same IP:PORT. Applications can use getReusePort() to determine the initial setting of SO_REUSEPORT.


on - whether to enable or disable the socket option


SocketException - if an error occurs enabling or disabling the SO_RESUEPORT socket option, or the socket is closed.

public boolean getReusePort()

                        throws SocketException

Tests if SO_REUSEPORT is enabled.


A boolean indicating whether or not SO_REUSEPORT is enabled.


SocketException - if there is an error in the underlying protocol, such as a TCP error.

Also add the SO_REUSEPORT to the SocketOptions in various files.

We implemented a prototype on JDK 8 and see very good results in HDFS latency reduction and network connection scaling; about ~1.9x improvement in latency for OSU HiBD Benchmark ( on a small cluster of 1 Namenode and 2 DataNodes.
We plan to port it to JDK 9 sources and submit it for consideration.
Please let us know if there is interest and if you would like to sponsor this patch.

Many applications, especially Linux or BSD based webservers such as Apache httpd and Nginx are already supporting it now. Ruby and Python have it supported as well. Other Java applications such as Netty webserver have it support it via JNI function since JDK has not supported it yet. Significant throughput and latency improvement have been observed from various applications.

Best Regards,


More information about the core-libs-dev mailing list