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

loadbalancer-experimental: allow configuring the pending request penalty #2991

Conversation

bryce-anderson
Copy link
Contributor

Motivation:

The pending request penalty is a way to try to avoid connections with lost of pending requests which results in a more even request distribution. However, the penalty is currently fixed which doesn't allow us to choose how to prioritize between the fastest hosts vs the most fair request distribution.

Modifications:

Make the penalty factor configurable.

Motivation:

The pending request penalty is a way to try to avoid connections with
lost of pending requests which results in a more even request distribution.
However, the penalty is currently fixed which doesn't allow us to choose
how to prioritize between the fastest hosts vs the most fair request
distribution.

Modifications:

Make the penalty factor configurable.
@@ -155,7 +158,7 @@ public final int score() {
// Add penalty for pending requests to account for "unaccounted" load.
// Penalty is the observed latency if known, else an arbitrarily high value which makes entities for which
// no latency data has yet been received (eg: request sent but not received), un-selectable.
final int pendingPenalty = (int) min(MAX_VALUE, (long) cPending * currentEWMA);
final int pendingPenalty = (int) min(MAX_VALUE, (long) cPending * pendingRequestPenalty * currentEWMA);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would arguably be better as a double since most useful values of this will center around the low single digits, most likely 0 and 1 being the most common. Otoh, maybe it's not worth letting people try to overthink it to find if 0.5 is better than 1. Feedback welcome.

Copy link
Member

Choose a reason for hiding this comment

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

  1. What range is currently expected for resulting pendingPenalty?
  2. Why do we use long for config parameters but cast it to int internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. realistic values range between 0 and probably 100 where 100 is effectively infinite.
  2. I used a long for consistency with other parameters such as errorPenalty and cancelPenalty, which could arguably be turned to ints themselves.

Copy link
Contributor Author

@bryce-anderson bryce-anderson Jul 1, 2024

Choose a reason for hiding this comment

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

I'm happy to switch from long to int but would prefer to do the same with the cancellation and error penalties if we do. That should make Integer.MAX_VALUE safe to use as without worrying about overflows. However, I suspect we'd want to go through a deprecation cycle for the long method. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

int is easier to operate with. If there is no need to have values larger than Integer.MAX_VALUE, +1 for changing to longs. if you are sure nobody used long methods outside our providers, simply change the type. if there is a risk, we need to go through deprecation

@@ -155,7 +158,7 @@ public final int score() {
// Add penalty for pending requests to account for "unaccounted" load.
// Penalty is the observed latency if known, else an arbitrarily high value which makes entities for which
// no latency data has yet been received (eg: request sent but not received), un-selectable.
final int pendingPenalty = (int) min(MAX_VALUE, (long) cPending * currentEWMA);
final int pendingPenalty = (int) min(MAX_VALUE, (long) cPending * pendingRequestPenalty * currentEWMA);
Copy link
Member

Choose a reason for hiding this comment

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

  1. What range is currently expected for resulting pendingPenalty?
  2. Why do we use long for config parameters but cast it to int internally?

Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

long -> int can be a follow-up

@bryce-anderson bryce-anderson merged commit c4198c2 into apple:main Jul 2, 2024
11 checks passed
@bryce-anderson bryce-anderson deleted the bl_anderson/pendingRequestPenaltyConfig branch July 2, 2024 19:42
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