[WIP/RFC v4 0/5] Support abstract Unix sockets
mdounin at mdounin.ru
Wed Aug 24 16:00:44 UTC 2022
On Wed, Aug 24, 2022 at 05:21:48PM +0200, Alejandro Colomar wrote:
> Hi Maxim,
> On 8/24/22 16:58, Maxim Dounin wrote:
> > Hello!
> > On Wed, Aug 24, 2022 at 01:00:26AM +0200, Alejandro Colomar wrote:
> >> I'll resend v4 in a moment, since it didn't arrive to the list.
> >> On 8/23/22 23:18, Alejandro Colomar wrote:
> >>> Hi,
> >>> Patch set ready for review.
> >>> Both 'listen' and 'proxy_pass' work fine, with the only caveat
> >>> that writing a NUL character in the nginx.conf file is not the
> >>> friendliest interface. I will add a few more patches to make '@'
> >>> a synonym for NUL, as many other projects do.
> >>> However, this patch set can be applied on its own if you prefer
> >>> to make them separate, since this one adds the feature in its
> >>> simplest way, and the upcoming patches are just making it more
> >>> user friendly. Please advice on your preferred way of proceeding.
> > A while ago a working implementation of Linux abstract namespace
> > sockets was already posted in this mailing list, see here:
> > https://mailman.nginx.org/pipermail/nginx-devel/2016-October/008878.html
> > It received zero interest and no tests/reviews, hence there are
> > no further work on this.
> I didn't know about that one, but found two others (one from 2012 and
> another from 2019). I based my v1 on the 2019 one, but then decided
> that I didn't like it and rewrote it from scratch.
> > If you think that Linux abstract namespace support is needed, you
> > may want to start with basic things, notably:
> >> Try to make it clear why the suggested change is needed, and
> >> provide a use case, if possible.
> Yeah, that's the most important thing. I mentioned it in v1, which also
> didn't reach the mailing list :(. I'll restate here.
> For having nginx as a reverse proxy in front of a server, such as unit,
> it's faster to communicate through Unix sockets (UDS), rather than TCP
I would rather say "it's a common misconception that it's faster
to communicate through Unix sockets". While it Unix sockets can
be beneficial for some microbenchmarks, in most production setups
it makes no difference, yet used to introduce various issues.
> Nginx already supports UDS. But UDS has a problem: the
> kernel creates a file in the fs, and it's not always trivial to clean up
> those files. Then, if the application is restarted, there's no
> SO_REUSEADDR to allow reusing the socket file, so the application will
> just fail.
> This happens in nginx Unit, which creates listener sockets from a
> privileged thread, and then uses them from unprivileged threads. When
> the unprivileged thread stops using the socket, it can't remove the
> file, and doing so would require huge complexity to implement. It's
> easier to just tell the kernel we want an abstract UDS (AUDS), so that
> there's no file at all. Then if the user restarts Unit, it'll be able
> to recreate the AUDS.
> A user reported this problem with normal UDS and we concluded that the
> easiest solution would be to add support for AUDS. His set-up is a
> kubernetes pod, where a container uses nginx and another container uses
> Unit. Communicating through an AUDS would be trivial and fast.
So, you are trying to implement abstract namespace sockets as a
bandaid for Unit bug, which is not able to properly remove Unix
sockets in some cases and fails to restart, correct? This does
not look like a valid reason to me, especially given that a)
abstract namespace sockets are Linux-only, and b) there are
multiple approaches to filing the abstract socket address.
More information about the nginx-devel