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

balancer: start populating weight by edsbalancer for weighted_round_robin #2945

Merged
merged 9 commits into from
Aug 6, 2019

Conversation

alazarev
Copy link
Contributor

Weight is stored as wrr.Info in Address metadata.

…weight in metadata version).

Weight is stored as wrr.Info in Address metadata.
const Name = "weighted_round_robin"

// Information that should be stored inside Address metadata in order to use wrr.
type Info struct{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's make it an interface, e.g.

type Weighted interface {
  Weight() uint32
}

?

This would allow us to provide some object with xds-specific knowledge (e.g. is it a canary instance?) in the future, which would also implement the Weighted interface among others.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it may make sense to move this interface to the balancer package itself, as it's possible it would be used by other weight-aware load balancers, e.g. maglev.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with interface is, it's hard to add methods. But for structs, we can add fields.

I also think it's better to not keep it in balancer package, because it's more like a feature of a specific balancer, not all balancers.

balancer/wrr/wrr.go Outdated Show resolved Hide resolved
balancer/wrr/wrr.go Outdated Show resolved Hide resolved
balancer/xds/edsbalancer/edsbalancer.go Outdated Show resolved Hide resolved
@@ -60,7 +61,7 @@ type baseBalancer struct {
csEvltr *balancer.ConnectivityStateEvaluator
state connectivity.State

subConns map[resolver.Address]balancer.SubConn
subConns map[resolver.Address]AddrInfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With changes in this file, we will still unnecessarily reconnect when the weight for an address changes.
To avoid that, we should clear metadata field when addresses are received.
But this changes the behavior.

Base is to be used as an example, and in the case only picking algorithm is different.
I think we should leave base package as is, and re-implement this for wrr.

wrr will have some special behaviors, some I can think of now:

  • Duplicates in addresses list (same address string, but multiple entries in addrs list, with potential different metadata)
    • Should we add up the weights?
  • Since metadata is not hashed, the only useful thing is the address string itself. Maybe we should use the string as the key, instead of the address struct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this care diff becomes really small, just weightedroundrobin package declaration with metadata population in edsbalancer. Updated pull request.

Reverted balancer/base/balancer.go
Renamed wrr.Info to weightedroundrobin.AddrInfo
Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Two small nits. Thanks!

balancer/xds/edsbalancer/edsbalancer.go Outdated Show resolved Hide resolved
balancer/xds/edsbalancer/edsbalancer.go Outdated Show resolved Hide resolved
@alazarev
Copy link
Contributor Author

alazarev commented Aug 2, 2019

Updated

@alazarev alazarev changed the title Introduce PickerBuilderV2 that can take address weight into account. Start populating weight by edsbalancer for weighted_round_robin balancer Aug 5, 2019
@alazarev
Copy link
Contributor Author

alazarev commented Aug 5, 2019

Updated title to match reality

@menghanl menghanl changed the title Start populating weight by edsbalancer for weighted_round_robin balancer balancer: start populating weight by edsbalancer for weighted_round_robin Aug 5, 2019
@alazarev
Copy link
Contributor Author

alazarev commented Aug 5, 2019

@menghanl Do you have an idea what continuous-integration/travis-ci/pr is complaining about? It shows no errors, but build is marked as failed.

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to make gofmt happy...

Run ./vet.sh to check locally.
Note that to run it, you cannot have uncommmited changes.

balancer/weightedroundrobin/weightedroundrobin.go Outdated Show resolved Hide resolved
balancer/weightedroundrobin/weightedroundrobin.go Outdated Show resolved Hide resolved
@alazarev
Copy link
Contributor Author

alazarev commented Aug 5, 2019

Updated. Looks like we are ready to merge.

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. LGTM.

@menghanl menghanl merged commit a2bdfb4 into grpc:master Aug 6, 2019
@menghanl menghanl added the Type: Feature New features or improvements in behavior label Aug 6, 2019
@menghanl menghanl added this to the 1.23 Release milestone Aug 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants