Hi Sandhya,

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

Roger


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

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 https://lwn.net/Articles/542629/

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/ServerSocket.java and 
java/net/Socket.java:

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.

Parameters:

on - whether to enable or disable the socket option

Throws:

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.

Returns:

A boolean indicating whether or not SO_REUSEPORT is enabled.

Throws:

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 (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



Reply via email to