-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
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 (or opt-out). 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.
Until this is fixed, if someone else also needs this you can take a look at https://github.com/CAFxX/balancer.