
Go 1.27: How Background resp.Body Draining Speeds Up HTTP/1 Fivefold
You have written defer resp.Body.Close() in Go services for years without realizing that over HTTP/1, that call was quietly tearing down sockets and burning CPU cycles on repeated TLS handshakes. Leaving even a single unread byte in the buffer—like a trailing newline after decoding JSON—caused net/http to flag the connection as dirty and evict it from the pool.
In Go 1.27, core engineers fixed that architectural trap with smart background draining. The transport now asynchronously reads the tail of the response behind the scenes (up to 256 KiB within 50 ms) and safely returns the socket to duty. Across a hundred-request run, latency dropped from 710 to 150 milliseconds without a single line of manual workaround code.


