-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Document the meaning of CPU requests & limits #50987
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
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Pull request preview available for checkingBuilt without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| ## How CPU requests and limits work under the hood | ||
|
|
||
| ### On Linux systems | ||
|
|
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.
Please wrap the long "lines" appropriately.
See https://sembr.org for the preferred line wrapping style.
|
I think this new section would be great as a page under https://kubernetes.io/docs/concepts/containers/ The existing task page can (should) link to that new concept page, and can also include a bit of a summary. |
Agree with @lmktfy here, I think this would be a great place for the content |
|
@pegagas, would you be willing to adapt this per #50987 (comment) ? You can, of course, keep all the words you've already written - it's just about where they go. |
|
|
||
| ### On Linux systems | ||
|
|
||
| In Linux, Kubernetes uses cgroups (control groups) to enforce CPU requests and limits. See the [RedHat documentation on cgroups](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/managing-cpu-resources-with-control-groups_managing-monitoring-and-updating-the-kernel) for more details. |
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.
This access.redhat.com link redirects to https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/managing-cpu-resources-with-control-groups_managing-monitoring-and-updating-the-kernel, which then returns 404: Page not found.
Linking to https://docs.kernel.org/admin-guide/cgroup-v2.html would be more future-proof (although maybe not very beginner-friendly), as the above link is specific to RHEL v8.
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.
great suggestion. I will raise another commit for these changes.
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.
Nice, thanks 🙂
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.
And thanks for adding this to docs, very useful 🙏
yes, I think it is good idea. will modify like that one. |
d83abb9 to
648dc7b
Compare
lmktfy
left a comment
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.
I have concerns about the technical accuracy of this PR. We shouldn't assume that container runtime rely on cgroups for CPU restrictions, even on Linux.
Overall, I think these new details belong in a separate page and not the overview concept page for containers.
Consider moving them to a leaf of the container concept.
We should not remove the existing useful content, such as explaining that containers are based on images.
|
|
||
| ### On Linux systems | ||
|
|
||
| In Linux, Kubernetes uses cgroups (control groups) to enforce CPU requests and limits. See the [RedHat documentation on cgroups](https://docs.kernel.org/admin-guide/cgroup-v2.html ) for more details. |
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.
This isn't RedHat documentation.
|
|
||
| #### CPU Limits | ||
| - Windows implements CPU limits using CPU caps. | ||
| - The limit is expressed as a percentage of total CPU cycles across all processors. |
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.
All processors, or all online processors?
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.
good catch!
I will modified this one.
| - For example, a limit of 0.5 CPU on a 2-core system means the container can use up to 25% of the total CPU cycles. | ||
| - Windows measures CPU usage over a longer time window compared to Linux, which can result in different throttling behavior. | ||
|
|
||
| {{< note >}} |
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.
I would not use a note here.
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.
sure. Done.
|
|
||
| #### CPU Limits | ||
| - CPU limits are implemented using CPU quota and period. | ||
| - The period is hardcoded to 100ms (100,000 microseconds). |
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.
Is this true across all Linux nodes? Ideally, provide a citation.
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.
we should be more careful about this one. deleted.
Update content/en/docs/concepts/containers/_index.md Co-authored-by: Tim Bannister <193443691+lmktfy@users.noreply.github.com> Update content/en/docs/concepts/containers/_index.md Co-authored-by: Tim Bannister <193443691+lmktfy@users.noreply.github.com> Update content/en/docs/concepts/containers/_index.md Co-authored-by: Tim Bannister <193443691+lmktfy@users.noreply.github.com> Update content/en/docs/concepts/containers/_index.md Co-authored-by: Tim Bannister <193443691+lmktfy@users.noreply.github.com> modify according latest comments
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
|
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
|
@k8s-triage-robot: Closed this PR. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Description
I have added a new section titled "How CPU requests and limits work under the hood", which explains in detail:
How CPU requests are translated into cgroups v1 shares or cgroups v2 weight
How CPU limits are implemented using a quota system with a fixed 100ms period
An explanation of CPU limiting, including concrete examples
Explanation of how CPU throttling works
The different implementation of CPU requests and limits
Explanation of how CPU caps are used to enforce limits in Windows
Explanation of how it works on multi-core systems
Issue
fix: #50308