noKeepAlive: Fresh TCP for Scaling Pods
Go's default HTTP client reuses TCP connections, bypassing DNS. With KEDA scale-down, reused connections point to dead pods. One setting fixes it.
The Problem
Go’s default HTTP client reuses TCP connections. That saves time when the server stays put. Chrome pods are not a fixed server. KEDA scales them up and down. A reused connection can point to a pod that no longer exists.
Why Keep-Alive Bypasses DNS
A keep-alive connection is a direct TCP pipe to one pod IP. The client holds the pipe open. On the next request, the client sends data through the same pipe. It never asks DNS again.
The Fix
One setting. Every request opens a new TCP connection and closes it when done. The 5-second timeout prevents hanging on an unreachable pod.
var noKeepAliveClient = &http.Client{
Transport: &http.Transport{DisableKeepAlives: true},
Timeout: 5 * time.Second,
}
Three Defenses That Work Together
Remove any one and the system breaks in a different way.
Do not add a connection pool. A pool holds open connections to pod IPs that KEDA can remove at any time. Chrome pod HTTP calls must stay poolless.
References:
Related: see the headless Service that provides the pod IPs, or go back to the series overview.