This (rather old) article seems to suggest that two Unicorn master processes can bind to the same Unix socket path:
When the old master receives the QUIT, it starts gracefully shutting down its workers. Once all the workers have finished serving requests, it dies. We now have a fresh version of our app, fully loaded and ready to receive requests, without any downtime: the old and new workers all share the Unix Domain Socket so nginx doesn’t have to even care about the transition.
Reading around, I don't understand how this is possible. From what I understand, to truly have zero
downtime you have to use SO_REUSEPORT
to let the old and new servers temporarily be bound to the
same socket. But SO_REUSEPORT
is not supported on Unix sockets.
(I tested this by binding to a Unix socket path that is already in use by another server, and I got
an EADDRINUSE
.)
So how can the configuration that the article describes be achieved?
- Nginx forwards HTTP requests to a Unix socket.
- Normally a single Unicorn server accepts requests on this socket and handles them (fair enough).
- During redeployment, a new Unicorn server begins to accept requests on this socket and handles them, while the old server is still running (how?)