SO_REUSEPORT feature support in JDK 9 for socket communication (original) (raw)

Roger Riggs Roger.Riggs at Oracle.com
Thu Oct 22 13:04:44 UTC 2015


Hi Sandhya,

The folks on net-dev at openjdk.java.net will be interested too.

Roger

On 10/21/2015 9:08 PM, Viswanathan, Sandhya wrote:

This is a proposal for adding SOREUSEPORT 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 https://lwn.net/Articles/542629/ The proposal is to add the SOREUSEPORT feature on similar lines as SOREUSEADDR which was included in JDK7. Add the following two API methods to java/net/ServerSocket.java and java/net/Socket.java: public void setReusePort(boolean on) throws SocketException Enable/disable the SOREUSEPORT socket option. Enabling SOREUSEPORT 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 SOREUSEPORT. Parameters: on - whether to enable or disable the socket option Throws: SocketException - if an error occurs enabling or disabling the SORESUEPORT socket option, or the socket is closed.

public boolean getReusePort() throws SocketException Tests if SOREUSEPORT is enabled. Returns: A boolean indicating whether or not SOREUSEPORT is enabled. Throws: SocketException - if there is an error in the underlying protocol, such as a TCP error. Also add the SOREUSEPORT 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 (http://hibd.cse.ohio-state.edu/downloads/) 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, Sandhya



More information about the core-libs-dev mailing list