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
Implement Balanced Resource Allocation (BRA) algorithm as a PriorityFunction in scheduler package. #6150
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/. If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits. Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name. |
CLAs look good, thanks! |
I'd rather we don't use the word "Usage" for "Requested divided by Capacity", unless there is some existing standard for naming these things, which I'm unaware of. To me, "Usage" is an absolute quantity, not a ratio. And, without qualifiers, it is a measure made by the operating system, not kubernetes pod requests. See for example, the Linux kernel cpuacct.usage cgroup file. Call this PctOfCapRequested or something. |
By the same logic, please don't call this Utilization. IIUC, when people talk about utilization in a datacenter, without any qualifiers, they mean usage divided by capacity, not request divided by capacity. Maybe call this Balanced Node Fullness, or something. |
Hi, @erictune Thank you for your comments. I agree that using the word "Usage" for "Requested divided by Capacity" is not proper, and they will be replaced by "PctOfCapRequested" in both code and the PR message. Regarding the word "Utilization" in Balanced Resource Utilization, this word is actually used in 2 research articles, i.e.
However, if this word is confusing in this scenario, I plan to change it to Balanced Resource Allocation. What do you think? |
Need some time, trying to fix check failure ASAP. |
Hi, folks My last commit has failed the continous-integration check and the reason is (as given by the details from https://travis-ci.org/GoogleCloudPlatform/kubernetes/jobs/56587523):
However, I can not reproduce this error in my local environment, i.e. I am confused about this right now, so it would be great if someone could give any advice on this. Big thanks in advance! |
@HaiyangDING Seems to be an unrelated error due to a timeout - I would just retry the test. One way to kick off the tests again is to just modify the commit. |
I'll restart the tests. |
@HaiyangDING |
@erictune @abhgupta @bgrant0607 |
PTAL, I have fixed the code and the description. |
capacityMilliCPU := node.Status.Capacity.Cpu().MilliValue() | ||
capacityMemory := node.Status.Capacity.Memory().Value() | ||
|
||
cpuPctOfCapRequested := calculatePctOfCapRequested(totalMilliCPU, capacityMilliCPU, node.Name) |
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.
suggest cpuFraction as the variable name. (and memoryFraction, averageFration below)
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.
Sorry for disagreeing with previous reviewer :(
} else { | ||
score = int(1 / diff) | ||
} | ||
// if Requesetd/Capacity exceeds 100%, the PctOfCapRequested is set to 1 (100%) and the host should never be preferred. |
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.
Why not just directly check for request >= capacity above (before the call to calculatePctOfRequested) and return early if so?
Thanks for this change! I have a few comments. They're mostly minor. Please squash your commits, in case I forget to ask later. |
Hi, thank you for the comments. I have just returned from a small vacation. Will be working on it sooner. |
New patch submitted at my home where tests are unable to perform, I will fix them tomorrow. Sorry for the trouble. |
"baz": "blah", | ||
} | ||
machine1Status := api.PodStatus{ | ||
Host: "machine1", |
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.
Needs to be rebased. This field is gone.
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.
Thank you, I will fix them.
How to deal with Shippable failures? I can not see the details. |
Shippable is an unrelated flake. Last request before LGTM: document sources, and squash commits again. Thanks! |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
I confirm that all contributors to this PR are OK with these commits being contributed to Google. As a matter of fact, the commits are all made by me (dingh, HaiyangDING, dinghaiyang@huawei.com) but throught different PCs PS: I will squash all the commits as I did in HaiyangDING@15b91cd later |
I confirm that all contributors to this PR are OK with these commits being contributed to Google. As a matter of fact, the commits are all made by me (dingh, HaiyangDING, dinghaiyang@huawei.commailto:dinghaiyang@huawei.com) but throught different PCs 丁海洋Haiyang DING, 发件人: googlebot [mailto:notifications@github.com] We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. — |
I think I have squashed all the commits, but it seems I have to do I wonder if it is OK. Please bear me with this, I am new to squashing and let me know if anything should be done. ------------------- details of last steps of openstack@network: |
@HaiyangDING use fetch + rebase instead of pull + merge to prevent that. |
CLAs look good, thanks! |
Balanced Resource Allocation policy can now be enabled to so that host(s) with balanced resource usage would be preferred. The score given by BRA also scales from 0 to 10 with 10 representing that the resource usage is well balanced.
PTAL, finally it works... thanks |
LGTM, thank you! |
Implement Balanced Resource Allocation (BRA) algorithm as a PriorityFunction in scheduler package.
This PR implements issue #5783.
Why BRA
In the current PriorityFunction libraries, the only function considering the resource utilization is the LeastRequestedPriority function which would lead to imbalanced resource allocation in some case. For instance, given two hosts with the same capacity {cpu: 10000, mem: 100000}, the current occupied resource is shown below:
when a pod with {cpu: 2000, mem: 10000}, the LeastRequestedPriority would score the two hosts as:
host1:
host2:
one can see that
host1.score
equals tohost2.score
, in which case the algorithm would select either host1 or host2 based on a random decision. However, it is clear that if host2 is chosen the resource usage rate would be imbalanced with 80% cpu occupied and only 20% memory used, leaving 80% as "resource fragment".Balanced Resource Allocation algorithm is here to address such problem. The rational underlying the algorithm is, for each host, evaluating the usage percentage of the resources (cpu and memoy in our case) assuming the pending pod already scheduled on that host and rating the host based on how balanced the concerned resources are used. That is to say, host with similar cpu usage percentage and memory usage percentage would be preferred over those without.
As for the example above, host1 would be preferred over host2 as host1 would end up with a more balanced resource usage rate.
Details of BRA
The score given by BRA is scaled from 0-10 with 10 being preferred. This goes with other PriorityFunctions. Note that BRA implemented here considers only the percentage of requested resource over capacity without taking into account the actual free resources on the host. Thus, BRA PriorityFunction should NEVER be used alone and MUST be used collaboratively with LeastRequestedPriority function.
Here are the steps showing the score is calculated:
step1: calculate the cpuFraction and memoryFraction
step2: calculate the difference
step3: scale the difference to 0~10 and subtract by 10 to get the score
PS
PS1: If
requested >= capacity
, score is set to 0 directly so that host with such high resource usage would not be preferred.PS3: For the example mentioned above, the final score would be:
so host1 is preferred by BRA function.