| Better HTTP/1 connection reuse in Go 1.27(go.dev) | |
| 295 points by allddd 1 day ago | 46 comments | |
tl;dr: Go 1.27's `net/http.Transport` now automatically drains unread HTTP/1 response bodies (up to 256 KB or 50 ms, asynchronously), enabling connection reuse in cases where it previously failed—yielding up to 5x speedups for code that doesn't fully consume response bodies. Previously, developers had to manually drain bodies with tricky workarounds involving size caps, timeouts, and background goroutines to avoid repeatedly paying TCP/TLS handshake costs. The new recommendation is to simply `defer resp.Body.Close()` and let the standard library handle it. | |
HN Discussion:
| |