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

`ss -ltn` shows the listener for port 8080 with `Recv-Q 129` and `Send-Q 128`, and clients hang on connect.

AdvancedTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer

Likely causes → For a listening socket, Recv-Q is the current accept queue length and Send-Q is its maximum. Recv-Q above Send-Q means the accept queue is full: the handshake completed in the kernel, but the app isn't calling accept() fast enough (event loop blocked, all worker threads busy, GC pause). Further final ACKs are dropped and clients retransmit.

Diagnose →

watch -n1 "ss -ltn 'sport = :8080'"
nstat -az TcpExtListenOverflows TcpExtListenDrops
top -H -p $(pgrep -f myapp)         # are all workers pegged?

Fix → Fix the slow consumer first (more workers, non-blocking I/O, offload slow work). Then raise the backlog: the effective value is min(listen() backlog, net.core.somaxconn), so increase both.

sudo sysctl -w net.core.somaxconn=4096
# and in the app, e.g. gunicorn --backlog 4096

Prevent → Export ListenOverflows and alert on any increase; load test with realistic concurrency.

All Networking questions Roadmap: Networking for DevOps

More on Sockets, ports, TIME_WAIT and conntrack