net/http: add Transport.MaxIdleConns limit #15461
Closed
Comments
So |
CL https://golang.org/cl/22492 mentions this issue. |
gopherbot
pushed a commit
that referenced
this issue
Apr 27, 2016
…r closes Previously the Transport would cache idle connections from the Transport for later reuse, but if a peer server disconnected (e.g. idle timeout), we would not proactively remove the *persistConn from the Transport's idle list, leading to a waste of memory (potentially forever). Instead, when the persistConn's readLoop terminates, remote it from the idle list, if present. This also adds the beginning of accounting for the total number of idle connections, which will be needed for Transport.MaxIdleConns later. Updates #15461 Change-Id: Iab091f180f8dd1ee0d78f34b9705d68743b5557b Reviewed-on: https://go-review.googlesource.com/22492 Reviewed-by: Andrew Gerrand <adg@golang.org>
CL https://golang.org/cl/22655 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There's been a long-standing TODO in net/http.Transport that says:
This bug is about that.
We already have
Transport.MaxIdleConnsPerHost
, but it's been requested by many (and again recently) that we have aTransport.MaxIdleConns
for any host.In the process, I also noticed that we're not aggressively removing cached connections when the peer server disconnects. We only lazily clean them up from the idle structures, which means we can hold onto memory for the bufio.Readers/Writers for a long time, wasting memory.
/cc @adg
The text was updated successfully, but these errors were encountered: