net: Introduce round-robin connection balancing policy#3371
Open
tgrabiec wants to merge 1 commit into
Open
Conversation
Useful for some protocols which assume this policy, like shard-aware CQL protocol, which keeps opening connections until it hits the desired shard. With the current default load balancing strategy, which picks the least-loaded shard, that is not guaranteed to converge and can live-lock if there is connection imbalance.
Contributor
Author
|
Needed by ScyllaDB: scylladb/scylladb#29687 |
nyh
approved these changes
Apr 30, 2026
| port, | ||
| // This algorithm distributes all new connections to listen_options::fixed_cpu shard only. | ||
| fixed, | ||
| // This algorithm distributes new connections to shards in a round-robin fashion, |
Contributor
There was a problem hiding this comment.
nitpick: typo in the commit message title ("balaning").
| class conntrack { | ||
| class load_balancer { | ||
| std::vector<unsigned> _cpu_load; | ||
| unsigned _rr_counter = 0; |
Contributor
There was a problem hiding this comment.
nitpick: If you're familiar with this code, you can guess that the acronym "rr" refers to round-robin, but it's not obvious. I would add a comment that this variable is used by load_balancing_algorithm::round_robin to choose the next shard.
| return cpu; | ||
| } | ||
| shard_id next_cpu_rr() { | ||
| auto cpu = shard_id(_rr_counter % smp::count); |
Contributor
There was a problem hiding this comment.
Note that in #3355 @avikivity deprecates smp::count, so this call will need to be fixed (in the same way Avi fixed the lines above).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Useful for some protocols which assume this policy, like shard-aware CQL protocol, which keeps opening connections until it hits the desired shard. With the current default load balancing strategy, which picks the least-loaded shard, that is not guaranteed to converge and can live-lock if there is connection imbalance.