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

net/http: Client round-robin across persistent connections #34511

Open
CAFxX opened this issue Sep 25, 2019 · 2 comments

Comments

@CAFxX
Copy link
Contributor

commented Sep 25, 2019

When connecting directly to a service spread across multiple hosts with DNS "load-balancing" it would be ideal if http.Client could round-robin requests over persistent connections to the multiple hosts listed in the A record.

Right now, if you want to ensure that load is balanced the only practical option is to disable HTTP keepalives.

One way this could be done is to have idle connection pools for each different A record, and do a DNS resolution for every request to decide which pool to use for that request.

This round-robin mode should likely be opt-in. When enabled, given a DNS record like the following:

example.local   60   IN   A   10.0.0.1
example.local   60   IN   A   10.0.0.2

http.Client would send roughly half the requests to .1 and half to .2, even when using persistent connections, and even if the client only ever sends requests serially.

@agnivade agnivade changed the title http.Client round-robin across persistent connections net/http: Client round-robin across persistent connections Sep 25, 2019
@agnivade

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

@agnivade agnivade added this to the Unplanned milestone Sep 25, 2019
@bradfitz

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

Agreed. I've been thinking about things like this as part of #23707 and making the connection pool interface more explicit/configurable. Currently it's a pretty hidden detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.