-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Standardization of weights for load-balancing #4198
Comments
Hi, As HAProxy's DNS stack maintainer, I'd be glad to see such feature in Consul. Note that HAProxy does not follow-up SRV record "prio" for now. We have some use cases in mind for this field, but are not yet sure how to implement them. Baptiste |
Hey! We definitely like this idea, agree with all your points on the benefits. A couple notes.
{
"Priority": {
"passing": 1,
"warning": 1
},
"Weight": {
"passing": 10,
"warning": 1
}
}
Let us know how we can help! |
cc: @wdauchy |
Adding this datastructure will allow us to resolve the issues hashicorp#1088 and hashicorp#4198 This new structure defaults to values: ``` { Passing: 1, Warning: 0 } ``` Which means, use weight of 0 for a Service in Warning State while use Weight 1 for a Healthy Service. Thus it remains compatible with previous Consul versions.
@pearkes Sure, I made a first implementation in #4468, and a review would help. I kept the exact plan you described in your last comment - but I did not implement priority since its semantics are clear for no-one :-) My first implementation only update weights in SRV records, but does not apply the weights in DNS A/AAAA queries. But this can be implemented later. The patch is big enough for now and I'll implement A/AAAA DNS in another review. @banks Nice to see that our discussion allowed me to plug nicely with new Connect features as well since Weights are already implemented in it! See #4468 (comment) for an example of input and DNS SRV output |
* Implementation of Weights Data structures Adding this datastructure will allow us to resolve the issues #1088 and #4198 This new structure defaults to values: ``` { Passing: 1, Warning: 0 } ``` Which means, use weight of 0 for a Service in Warning State while use Weight 1 for a Healthy Service. Thus it remains compatible with previous Consul versions. * Implemented weights for DNS SRV Records * DNS properly support agents with weight support while server does not (backwards compatibility) * Use Warning value of Weights of 1 by default When using DNS interface with only_passing = false, all nodes with non-Critical healthcheck used to have a weight value of 1. While having weight.Warning = 0 as default value, this is probably a bad idea as it breaks ascending compatibility. Thus, we put a default value of 1 to be consistent with existing behaviour. * Added documentation for new weight field in service description * Better documentation about weights as suggested by @banks * Return weight = 1 for unknown Check states as suggested by @banks * Fixed typo (of -> or) in error message as requested by @mkeeler * Fixed unstable unit test TestRetryJoin * Fixed unstable tests * Fixed wrong Fatalf format in `testrpc/wait.go` * Added notes regarding DNS SRV lookup limitations regarding number of instances * Documentation fixes and clarification regarding SRV records with weights as requested by @banks * Rephrase docs
References: * hashicorp/consul#4468 * hashicorp/consul#4198 Change-Id: I808fc90f3dd87b43bcf6325edb9cab8bbadffe60
Consul recentlty added support for service weights. (see hashicorp/consul#4198). This change adds the new field to the CatalogService class.
Consul recentlty added support for service weights. (see hashicorp/consul#4198). This change adds the new field to the Service and CatalogService classes.
* Add Weights property to Service and CatalogService Consul recentlty added support for service weights. (see hashicorp/consul#4198). This change adds the new field to the Service and CatalogService classes. * Use latest (1.2.3) consul version for travis
With the latest consul version services can have weights (see hashicorp/consul#4198). This change takes them into account when retreiving the endpoint list in the client.
Feature Description
When using Consul to discover backends for reverse proxies, there is now way to guess the weight of a given backends.
Since backends are running on different nodes, I would be nice to standardize in Consul how much calls are redirected to a given instance, thus all proxies and libraries might be using the same rules. Historically, some proxies / libraries are using tags, some other start using Meta in instances, but all of this is a mess.
Some proxies are using DNS SRV (eg: HaProxy), some other HTTP APIs, it would be nice to have the same data for both.
I propose the following:
Implementation proposal
When defining a service, use the following optional service Meta:
When DNS return SRV requests, for each SRV record, apply the corresponding
_dns_<state>_weight
and_dns_<state>_prio
to fill DNS SRV recordsThis could be very easily implemented and would simplify a lot interoperability of Load balancing systems.
Optionally, we might also use similar meta data at node level (defined in the agent) in order to multiply those weights based on node characteristics (thus services would not have to know on what kind of large/tiny instance they are running) - but it could be a improvement for another PR.
What do you think?
I am ready to implement this if Hashicorp considers including it.
The text was updated successfully, but these errors were encountered: