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.
The shared client in
server.servestarts withsafehttp.New, which clones Go's default transport.MaxIdleConnsPerHostremains zero, giving an effective per-host idle limit of 2, andResponseHeaderTimeoutremains zero. Passing this client tofetch.NewFetcherthroughfetch.WithHTTPClientreplaces 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
httptestupstream 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.