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

RandomizedWeightedBalancer chooses the first upstream with higher probability than others #666

Open
astsiapanay opened this issue Jan 31, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@astsiapanay
Copy link
Collaborator

Supposing we have 10 upstreams with equal weight = 1.

The current algo selects a random value from the range [0, upperBound] where upperBound in inclusive
calculates prefixSums for each upstream:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10

Later the algo finds the first index at prefixSums where

prefixSum[index] >= randomValue

where index is an index of the upstream to be selected

The problem is that all upstreams have equal ranges, the random value may be in except for the 1st upstream

[0,1],[2,2],[3,3],...,[10,10]

So the 1st upstream have in twice more possibility to be chosen than others.

@astsiapanay astsiapanay added the bug Something isn't working label Jan 31, 2025
@astsiapanay astsiapanay self-assigned this Jan 31, 2025
astsiapanay added a commit that referenced this issue Jan 31, 2025
astsiapanay added a commit that referenced this issue Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant