4 ms·
Unless you have really long-lived connections you cannot drop, let your load balancer layer above the machine drain old connections and then just restart after
by kortilla 6y ago
Unless you have really long-lived connections you cannot drop, let your load balancer layer above the machine drain old connections and then just restart after some threshold. I’ve seen too many bugs in socket handover scenarios to make it worth it in basically every normal use case.
Remember, just handing over your sockets means you get connections in all kinds of different phases of your protocol’s state machine. So now you need to bolt on some more context transfer mechanisms as well...
- anonymoushn 6y agoTFA is about handing over server sockets, so that the new version can deal with new connections while the old version deals with old connections. I have done this for an RTMP server. It worked out pretty well.
- geocar 6y agoIf you can do that, maybe you can just use SO_REUSEPORT and arrange for SIGTERM to close the listening socket before going into the drain phase.
- anonymoushn 6y agoThat does seem like it would have worked and been easier.
- WJW 6y agoSO_REUSEPORT has only been supported since about 2013 though, the trick with passing the fd over a Unix socket has worked for way longer than that.
- kortilla 6y agoThat only works when a session is a 1:1 relationship with a connection (e.g. a TCP service with sessions that can’t span TCP connections). That assumption falls apart with UDP, multiple TCP connections sharing session identifiers, etc. The world of QUIC means the kernel is a little too out of the loop for this to easily work.