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

Add optional round-robin channel selection for affinity binding calls. #127

Merged
merged 1 commit into from May 12, 2022

Conversation

nimf
Copy link
Collaborator

@nimf nimf commented May 11, 2022

Currently a binding call (as any other call without an affinity key) gets the least busy channel, i.e. channel that has fewest active streams. The current logic may not suit all the cases for binding new affinity keys in an optimal way.

It works well when the upstream issues bind calls infrequently and uses the affinity keys from these calls immediately. This way the channels used for the bind calls get utilized by the time a next bind call is issued and affinity keys remain balanced across channels.

But if the upstream makes several bind calls one after another and does not use the returned affinity keys right away, then the affinity keys will not be balanced.

For example:

Let's assume we have this situation: we have 3 long running calls on channel 1 and 3 each and 1 call on the channel 2:

Channels Affinity keys Active streams
1 5 3
2 5 1
3 5 3

New bind call arrives and gets routed to channel 2 because it has the fewest active streams.
The bind call returns 5 new affinity keys that is bound to channel 2:

Channels Affinity keys Active streams
1 5 3
2 10 1
3 5 3

Another bind call arrives and gets another 5 new keys:

Channels Affinity keys Active streams
1 5 3
2 15 1
3 5 3

This pattern may be continued to incur more imbalance.

If the upstream always requests the bind calls with a fixed number of affinity keys and never does unbind calls then we can round-robin bind calls to guarantee balanced distribution of affinity keys.

This PR introduces the option to round-robin bind calls.

@nimf nimf requested a review from mohanli-ml May 11, 2022 01:11
@nimf nimf merged commit 9233b35 into GoogleCloudPlatform:master May 12, 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