-
Notifications
You must be signed in to change notification settings - Fork 562
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
feat: use weighted round robin in balancedPool #1069
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1069 +/- ##
==========================================
+ Coverage 94.90% 96.37% +1.47%
==========================================
Files 50 37 -13
Lines 4608 2785 -1823
==========================================
- Hits 4373 2684 -1689
+ Misses 235 101 -134
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could use more comments in the code explaining the algorithm and also maybe some references to the paper.
a2ad318
to
904e045
Compare
I still have to fix the comments and make them better |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you test this against a few scenarios:
- an upstream is unavailable from the start, the algorithm should successfully route requests to working peers.
- the upstream become online. Request should start be fulfilled by the new upstream.
- the upstream go offline again. Requests should be routed to other upstreams.
Rebase main and you will get kNeedDrain to use instead of busy. |
@jodevsa you still intend to work on this? |
@ronag yeah, but no time right now :( I might be able to work on it on Saturday. Please feel free to take over if this thing is blocking you :) |
Not blocking. Just curious. |
7e971bc
to
c4826ec
Compare
@mcollina please don't review yet. I need to make the tests more understanable |
63eab1d
to
47eb207
Compare
Can I help with this one? |
Go for it! |
@mcollina are the only remaining items the unaddressed comments and conflicts, or there is something else? |
Unsure, this PR is still a draft from the author. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Hi guys, what are the next steps for getting this merged? are we missing more reviewers? |
Having @ronag would have been nice but he looks busy. Let's ship this. |
pool[kWeight] = Math.max(1, pool[kWeight] - this[kErrorPenalty]) | ||
this._updateBalancedPoolStats() | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This event handlers need to be removed in removeUpstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good find! I'll open another PR to address your comments
@@ -100,10 +145,42 @@ class BalancedPool extends PoolBase { | |||
return | |||
} | |||
|
|||
this[kClients].splice(this[kClients].indexOf(dispatcher), 1) | |||
this[kClients].push(dispatcher) | |||
const allClientsBusy = this[kClients].map(pool => pool[kNeedDrain]).reduce((a, b) => a && b, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.every
* fixes * more fixes * add test * remove console.log * rename startingWeightPerServer to maxWeightPerServer * add another test
* fixes * more fixes * add test * remove console.log * rename startingWeightPerServer to maxWeightPerServer * add another test
#1065