Go 1.27 introduces significant improvements to HTTP/1 connection reuse, reducing latency in network operations.
Go 1.27 introduces significant improvements to HTTP/1 connection reuse, reducing latency in network operations. Testing revealed that calling a simple HTTP GET function 100 times against index.golang.org took approximately 710 milliseconds in Go 1.26 but only 150 milliseconds in Go 1.27 on the same hardware, representing nearly a fivefold speedup. This optimization stems from how Go handles unread response bodies during connection reuse. In HTTP/1, connections can only be reused if the entire response body is consumed before initiating a new request. Earlier versions of Go failed to properly manage partially read bodies, causing connections to be abandoned unnecessarily. For instance, when only the status code was needed—such as in health checks—developers often overlooked reading the full response body, leading to repeated connection overhead. Go 1.27 addresses this by automatically draining unread bodies asynchronously within a 50-millisecond window or up to 256 kilobytes, whichever comes first. This change eliminates the need for manual workarounds like custom draining functions, which previously introduced complexity and potential bugs. The net/http Transport now handles these edge cases internally, ensuring more efficient reuse of existing TCP connections. While HTTP/2 has long avoided this issue through multiplexed streams, HTTP/1 remains prevalent in many environments. The update maintains backward compatibility while enhancing performance for common use cases. Users are advised to continue closing response bodies as needed, trusting the standard library to manage connection reuse efficiently without additional intervention.
- Publisher
- Hacker News
- Reliability
- high
- Published
- 10/15/2026, 8:50:28 AM
- Retrieved
- 10/15/2026, 8:50:28 AM
- Relevance
- 80%
- Confidence
- 85%

