2 ms·
> Running out of ports may affect short-lived connections too: by default when you (the client) close a connection, it goes into a ‘TIME_WAIT’ state that locks
by MBCook 5y ago
> Running out of ports may affect short-lived connections too: by default when you (the client) close a connection, it goes into a ‘TIME_WAIT’ state that locks up the {src,dst}_{ip,port} quadruple for (by default) 2 minutes to protect new connections with that quadruple getting packets that were meant for the previous connection.
This bit hard at a previous job. A very important PHP script would open DB connections (no pooling) and when it’s load hit the magic threshold we started running out of ports. But requests would succeed as TIME_WAIT expired so it just looked like some requests would hang with no reason.
It was tough for us to figure out. The final solution was obvious (pooling) but that took some doing because the script was quite old and it took a bit of an overhaul for that to work. Don’t remember exactly why. Tech debt is fun.
But we learned a new thing we had to be careful of, and a new failure mode we never expected.