Re: SO_REUSEPORT feature support in JDK 9 for socket communication
Hi Sandhya, The folks on net-dev@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
Re: SO_REUSEPORT feature support in JDK 9 for socket communication
On 22/10/2015 14:04, Roger Riggs wrote: Hi Sandhya, The folks on net-dev@openjdk.java.net will be interested too. Yes, net-dev is the best list for this. One other thing to mention is the SocketOption interface and the setOption/getOption methods. This allows for platform or JDK-specific specific socket options, it also allows it to be implemented by the NIO SocketChannel and friends. -Alan
Re: SO_REUSEPORT feature support in JDK 9 for socket communication
On 22/10/15 14:24, Alan Bateman wrote: On 22/10/2015 14:04, Roger Riggs wrote: Hi Sandhya, The folks on net-dev@openjdk.java.net will be interested too. Yes, net-dev is the best list for this. One other thing to mention is the SocketOption interface and the setOption/getOption methods. This allows for platform or JDK-specific specific socket options, it also allows it to be implemented by the NIO SocketChannel and friends. -Alan and there is the jdk.net API which extends this to the java.net socket types. I think a Java SE API would be fine if it is widely and consistently implemented across all the reference platforms and if it does not cause compatibility issues. If it only works on some platforms then maybe jdk.net could be the place for it. - Michael
Re: SO_REUSEPORT feature support in JDK 9 for socket communication
the following JBS item exists: https://bugs.openjdk.java.net/browse/JDK-6432031 search of windows documentation suggests that SO_REUSEPORT is still not an option man setsockopt on Solaris shows it as an option, but without precise description of semantics regards Mark On 22/10/2015 14:33, Michael McMahon wrote: On 22/10/15 14:24, Alan Bateman wrote: On 22/10/2015 14:04, Roger Riggs wrote: Hi Sandhya, The folks on net-dev@openjdk.java.net will be interested too. Yes, net-dev is the best list for this. One other thing to mention is the SocketOption interface and the setOption/getOption methods. This allows for platform or JDK-specific specific socket options, it also allows it to be implemented by the NIO SocketChannel and friends. -Alan and there is the jdk.net API which extends this to the java.net socket types. I think a Java SE API would be fine if it is widely and consistently implemented across all the reference platforms and if it does not cause compatibility issues. If it only works on some platforms then maybe jdk.net could be the place for it. - Michael