Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/http2: Strict handling of http.Transport.DisableKeepAlives in http2 #33260

Closed
maurice2k opened this issue Jul 24, 2019 · 3 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@maurice2k
Copy link

maurice2k commented Jul 24, 2019

What version of Go are you using (go version)?

go version go1.12.7 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

Using a http.Transport with http.Client and multiple concurrent outgoing http(s) connections. Basically load testing an http(s) endpoint.

Set http.Transport.DisableKeepAlives to true to enforce a single connection for each request.

What did you expect to see?

I was expecting to see n connections for n requests. This is true for http(s)/1.1 but http2 is re-using connections even though http.Transport.DisableKeepAlives is true.

I understand that this is not strictly a http2 feature but gets translated to http2 in func (t *http2Transport) disableKeepAlives() bool and thus should have the same meaning.

What did you see instead?

Works for http(s)/1.1 but http2 connections get re-used. In a test with n requests and a concurrency of c only ~c connections where used (instead of expected n connections).

How to fix?

See here: golang/net#48

Related issues

@FiloSottile
Copy link
Contributor

I remember @rsc looked into something similar.

@FiloSottile FiloSottile added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 30, 2019
@maurice2k
Copy link
Author

Can I help with something?

@gopherbot
Copy link

Change https://golang.org/cl/187958 mentions this issue: http2: make Transport.NewClientConn respect Transport.DisableKeepAlives

@golang golang locked and limited conversation to collaborators Oct 13, 2020
dteh pushed a commit to dteh/fhttp that referenced this issue Jun 22, 2022
While in http/1.1 the `http.Transport.DisableKeepAlives` directive disallows re-usage of the connection, in http2 it's currently implemented as "close the connection as soon as possible" (when the connection is idle).

Fixes golang/go#33260

Change-Id: I5c167029062168f53a2cd15b5fbd19c1589cf175
GitHub-Last-Rev: e35ab6278d5118605aa6de48ea625c099a427f6e
GitHub-Pull-Request: golang/net#48
Reviewed-on: https://go-review.googlesource.com/c/net/+/187958
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants