Skip to content

Tune the shared upstream transport defaults #327

Description

@andrew

The shared client in server.serve starts with safehttp.New, which clones Go's default transport. MaxIdleConnsPerHost remains zero, giving an effective per-host idle limit of 2, and ResponseHeaderTimeout remains zero. Passing this client to fetch.NewFetcher through fetch.WithHTTPClient replaces the fetcher's defaults of 10 idle connections per host and a 60-second response-header timeout.

For concurrent cache misses to one registry, only two connections can remain idle between bursts. This can add repeated TCP and TLS setup. An upstream which accepts a request and stalls before sending headers is bounded only by the client's overall timeout.

Add a TLS httptest upstream which counts accepted connections, run two concurrent request bursts, and measure how many connections the second burst reuses. A second case should stall before response headers and assert the intended timeout.

Use those measurements to choose the per-host idle limit. A starting point of 10 would match the fetcher default. Set a finite response-header timeout, with 60 seconds matching the fetcher default, unless measurements support another value.

Observed on v0.8.1 and current main at 94c11b4.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions