Skip to content

net/http: add Transport.MaxIdleConns limit #15461

@bradfitz

Description

@bradfitz

There's been a long-standing TODO in net/http.Transport that says:

type Transport struct {
....
    // TODO: tunable on global max cached connections
....

This bug is about that.

We already have Transport.MaxIdleConnsPerHost, but it's been requested by many (and again recently) that we have a Transport.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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions