Skip to content

proposal: net/http: Allow configurable max connection age #43905

Open
@dmarkhas

Description

@dmarkhas

Currently, the http.Transport implementation will reuse an HTTP connection if keepalives are enabled and the connection has not been in an idle state for too long.
This means that for high throughput connections that are always active and rarely/never exceed the IdleConnTimeout limit, the connection will keep getting reused (as long as it is not broken).

This poses a problem in terms of service discovery and client-side load balancing - since address resolution only happens in the dialer's DialContext, this leaves no chance for the client to re-resolve the target address since the same connection is constantly reused without ever "re-dialing".

I propose to add a MaxConnectionAge flag to http.Transport that would limit the lifetime of a persistent connection, and would not reuse it beyond this lifetime.

This would be in line with the behavior of go-grpc which also enforces a MaxConnectionAge limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions