Diagnostic step 1
Instrument and capture socket stats on upstream and proxy (ss -s, netstat -an | grep -E 'CLOSE_WAIT|TIME_WAIT') during a burst to confirm pool exhaustion.
Generated Oct 27, 2026, 9:31:39 AM
Instrument and capture socket stats on upstream and proxy (ss -s, netstat -an | grep -E 'CLOSE_WAIT|TIME_WAIT') during a burst to confirm pool exhaustion.
Configure an HTTP agent for node-fetch/undici with limited maxSockets (e.g., 50) and a keepAliveMsecs reasonable (e.g., 10000), share that agent across invocations where possible; test under load.
Use Connection: close only for pathological long requests as a temporary mitigation. Prefer bounding keep-alive instead.
Consider moving truly long-held requests to a backend job queue or use streaming/edge functions to reduce time serverless instances hold upstream connections.
If using a reverse proxy, increase its max connections and reduce TIME_WAIT/CLOSE_WAIT retention via proper keepalive and tcp_tw_reuse settings cautiously; monitor after change.