Bug 64850 - Add support to tomcat for JEP380: Unix domain sockets
Summary: Add support to tomcat for JEP380: Unix domain sockets
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 10
Classification: Unclassified
Component: Connectors (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ------
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-26 19:01 UTC by Graham Leggett
Modified: 2021-01-15 21:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Graham Leggett 2020-10-26 19:01:50 UTC
Native Java unix domain sockets are coming:

https://openjdk.java.net/jeps/380

It appears Tomcat needs to either support the following description, or be careful to not do anything that would break this description:

Description

To support Unix-domain socket channels we will add the following API elements:

A new socket address class, java.net.UnixDomainSocketAddress;

A UNIX constant value in the existing java.net.StandardProtocolFamily enum;

New open factory methods on SocketChannel and ServerSocketChannel that specify the protocol family

Updates to the SocketChannel and ServerSocketChannel specifications to specify how channels to Unix domain sockets behave.
Comment 1 Michael Osipov 2020-10-26 19:47:30 UTC
This could have happened years ago with https://github.com/kohlschutter/junixsocket. Do you plan to use with mod_proxy UDS support?
Comment 2 Mark Thomas 2020-10-27 17:20:06 UTC
Tomcat doesn't use the StandardProtocolFamily enum.

All casts to InetSocketAddress are preceded by a check that the cast is valid.

Supporting the configuration of a unix domain socket would require changes but I don't see anything here that would break the existing code.

Moving this to an enhancement.

I'll note that Tomcat support will need to wait until there is at least an EA release with an implementation and that support in Tomcat will need to be optional until the minimum Java version required by Tomcat includes this feature.
Comment 3 Christopher Schultz 2020-10-27 19:27:55 UTC
I honestly don't see the point of using UDS in Tomcat, ever. I'm not going to stop anyone from trying it, but:

1. UDS only works within a single kernel (so no inter-host communication)
2. TCP localhost is *really fast* and essentially boils down to shared kernel buffers

I'm sure performance data show that you can pump more bps through a UDS than you can through TCP, but how many one-box-wonders are there still out there that need to go REALLY FAST? If you are that concerned about latency and throughput, remove the reverse proxy and go straight to Tomcat.
Comment 4 Graham Leggett 2020-10-27 21:37:06 UTC
(In reply to Christopher Schultz from comment #3)
> If you are that concerned about latency and
> throughput, remove the reverse proxy and go straight to Tomcat.

Performance is largely irrelevant in this case. Unix domain sockets give you the unix permissions model, something you don't get with TCP.
Comment 5 Graham Leggett 2020-10-27 21:41:23 UTC
(In reply to Michael Osipov from comment #1)
> This could have happened years ago with
> https://github.com/kohlschutter/junixsocket. Do you plan to use with
> mod_proxy UDS support?

Yes.

Right now given that APR v1.6 and above support unix domain sockets it's possible that tomcat-native either supports this now already, or can be made to support this will minimal changes. On the case working out what changes are needed.

The purpose of this ticket is to make sure Tomcat supports JEP380 when it's ready.
Comment 6 Graham Leggett 2020-11-29 17:48:21 UTC
For reference, unix domain socket support has been proposed to tomcat-native here: https://bz.apache.org/bugzilla/show_bug.cgi?id=64942
Comment 7 Graham Leggett 2021-01-15 12:20:47 UTC
Thank you to @rmaucher - support for UDS now available for NIO:

https://github.com/apache/tomcat/commit/0d276556881446aa499fefd496d567606bc0ddec
Comment 8 Graham Leggett 2021-01-15 17:23:21 UTC
Tomcat-native v1.2.26 released with UDS support.

New patch proposed for APR here:

https://github.com/apache/tomcat/pull/401
Comment 9 Remy Maucherat 2021-01-15 21:49:21 UTC
No idea there was a BZ. Implemented in Tomcat 10.0.1 and 9.0.42.