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

Re-enable HTTP keep-alives now that net/http is fixed (as of Go 1.6!) #10

Merged
merged 1 commit into from Jun 15, 2022

Conversation

benhoyt
Copy link
Member

@benhoyt benhoyt commented Jun 15, 2022

Way back in 2013 we had added a workaround to a net/http bug
(see golang/go#4677, particularly rogpeppe's
comment) that involved closing the connection after each request:

However, that net/http bug was fixed in 2016 (in
https://go-review.googlesource.com/c/go/+/3210/ which was included in
Go 1.6), so we can re-enable this and significantly speed subsequent
requests to the same host when using juju/http. For comparison, the
net/http package enables keep-alives by default; we had only disabled
them due to that bug.

Some numbers: a full request to the Charmhub API takes about 1s from
New Zealand (to London, I believe) due mainly to latency from the
initial TLS negotiation. With DisableKeepAlives, subsequent requests
were of course taking the same time -- now subsequent requests take
only ~350ms.

Also add tests to ensure DisableKeepAlives is off by default -- doesn't
really test the feature (that's "too hard" to do well), but at least
ensures the correct values are being passed to http.Transport.

Way back in 2013 we had added a workaround to a net/http bug
(see golang/go#4677, particularly rogpeppe's
comment) that involved closing the connection after each request:

juju/utils@e5796c6
juju/utils@1d70ba9

However, that net/http bug was fixed in 2016 (in
https://go-review.googlesource.com/c/go/+/3210/ which was included in
Go 1.6), so we can re-enable this and significantly speed subsequent
requests to the same host when using juju/http. For comparison, the
net/http package enables keep-alives by default; we had only disabled
them due to that bug.

Some numbers: a full request to the Charmhub API takes about 1s from
New Zealand (to London, I believe) due mainly to latency from the
initial TLS negotiation. With DisableKeepAlives, subsequent requests
were of course taking the same time -- now subsequent requests take
only about 350ms.

Also add tests to ensure DisableKeepAlives is off by default -- doesn't
really test the feature (that's "too hard" to do well), but at least
ensures the correct values are being passed to http.Transport.
@benhoyt benhoyt merged commit 09678d3 into juju:master Jun 15, 2022
@benhoyt benhoyt deleted the reenable-keep-alives branch June 15, 2022 03:35
benhoyt added a commit to benhoyt/juju that referenced this pull request Jun 15, 2022
jujubot added a commit to juju/juju that referenced this pull request Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants