Interview Prep/Networking/Sockets, ports, TIME_WAIT and conntrack

During a rolling binary upgrade with `SO_REUSEPORT`, a fraction of requests still hit the old version and some get reset.

AdvancedTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer

Likely causes → With SO_REUSEPORT the kernel hashes new connections across all listening sockets in the group. While the old process is alive, it keeps receiving new connections. When it exits, connections already sitting in its accept queue (handshake complete, not yet accepted) are reset.

Diagnose →

sudo ss -ltnp 'sport = :8080'      # two PIDs listening on the same port
nstat -az TcpExtTCPAbortOnClose

Fix → Stop the old process's listener before it exits: close the listening socket, keep serving in-flight requests, then exit (graceful drain). Tools like nginx (nginx -s reload), HAProxy (-x socket transfer / seamless reload) and Envoy hot restart pass the listening FD instead of racing.

Prevent → Use FD passing / socket activation (systemd) for zero-downtime restarts, and test upgrades under load.

All Networking questions Roadmap: Networking for DevOps

More on Sockets, ports, TIME_WAIT and conntrack