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

Use GCD to reduce memory usage for WRR #51

Open
jizhuozhi opened this issue Mar 1, 2024 · 1 comment
Open

Use GCD to reduce memory usage for WRR #51

jizhuozhi opened this issue Mar 1, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jizhuozhi
Copy link

What is the problem your feature solves, or the need it fulfills?

The current WRR algorithm will have additional memory overhead when the weights are not mutually prime, and because the current implementation is not smooth, extreme situations will occur, causing the backend to be overloaded or starved.

For example, it is common for everyone to set the weight to 100 or 1000 to facilitate weight adjustment. Then there will be a situation where the first 100 are all A, and the next 100 are all B (smooth WRR or shuffling is another topic).

Describe the solution you'd like

Use GCD to reduce memory overhead and reduce load balancing cycles

Describe alternatives you've considered

What other solutions, features, or workarounds have you considered that might also solve the issue?
What are the tradeoffs for these alternatives compared to what you're proposing?

Additional context

Already implemented in the following RPC or gateway
cloudwego/kitex#1014
alibaba/tengine#1667

@jizhuozhi
Copy link
Author

jizhuozhi commented Mar 2, 2024

Sorry, I seem to have misunderstood the usage of Weighted here. It seems to be only used to weight the starting position of a sequence, and then fallback to an unweighted Round Robin. Why is it designed like this?

In addition, if you only for weighted selecting the starting position, the weighted expansion method is too cumbersome (O(sigma(w)) memory). Random methods such as CDF (cumulative density function, O(logn) time and O(n) memory cost) or alias method (O(1) time and O(n) memory cost) may be more suitable.

cloudwego/kitex#1184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants