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

iwrr: a wrr with always O(1) time and O(n) memory #1729

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

jizhuozhi
Copy link
Contributor

@jizhuozhi jizhuozhi commented Jan 25, 2023

An IWRR implementation likes lua-resty-balancer, but uses the double queue as same as the O(1) scheduler to avoid many rounds of pointless traversals to ensure always be O(1).

IWRR abandons smoothness on the premise of ensuring the correctness of the weighted load balancing algorithm. The memory overhead is only a queue with two sentinels, no matter how big the total weight is, only n + 2 elements of memory space will be allocated in the process, is more suitable for very large size clusters with different weights.

@jizhuozhi jizhuozhi force-pushed the master branch 2 times, most recently from 0e04a49 to 3f49543 Compare January 29, 2023 16:01
@jizhuozhi
Copy link
Contributor Author

jizhuozhi commented Feb 7, 2023

Hello, @chobits and @wangfakang . PLAT thanks :)

@lhanjian
Copy link
Collaborator

lhanjian commented Nov 3, 2023

abandons smoothness?

Can you give a specific example of this shortcoming?

@jizhuozhi
Copy link
Contributor Author

jizhuozhi commented Nov 3, 2023

Hello, @lhanjian .

There is no clear proof that the smoothness and stability of load balancing are positively correlated in large traffic scenarios.

In my opinion, in a large traffic scenario, no matter what algorithm, a complete load balancing cycle will be completed quickly, as long as the load balancing does not continuously select the same instance (eg, A:1, B:1 appear continuously likes AAAAABBBBB in 10 selections).

iwrr ensures that duplicate instances are avoided as much as possible within a continuous time window. For example, for the instance list A:1, B:2, C:3, D:4, E:5, then the sequence selected by iwrr is ABCDEBCDECDEDEE, but not ABBCCCDDDDEEEEE.

So I think this may not be a shortcoming, just a little difference from swrr.

@CLAassistant
Copy link

CLAassistant commented Nov 6, 2023

CLA assistant check
All committers have signed the CLA.

@jizhuozhi jizhuozhi force-pushed the master branch 2 times, most recently from d4f7beb to 000a79b Compare November 6, 2023 12:06
@jizhuozhi
Copy link
Contributor Author

Hello, @chobits . All issues are fixed, PTAL

@lhanjian lhanjian self-requested a review November 12, 2023 15:09
@lhanjian
Copy link
Collaborator

LGTM

@lhanjian lhanjian merged commit 8a7529d into alibaba:master Nov 23, 2023
9 checks passed
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

4 participants