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

clarify CPU and memory limit enforcement differences #46222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

haircommander
Copy link
Contributor

Clairify the container runtime and kubelet do not enforece memory limits, the kernel does. Also clarify that workloads won't always be OOM killed, and more clearly spell out the differences between memory and CPU limits

Clairify the container runtime and kubelet do not enforece memory limits, the kernel does.
Also clarify that workloads won't always be OOM killed, and more clearly spell out the differences
between memory and CPU limits

Signed-off-by: Peter Hunt <pehunt@redhat.com>
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 6, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign nate-double-u for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels May 6, 2024
Copy link

netlify bot commented May 6, 2024

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 24f6bef
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-io-main-staging/deploys/6638ef9e3882e8000810fc5e
😎 Deploy Preview https://deploy-preview-46222--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@sftim
Copy link
Contributor

sftim commented May 6, 2024

@kubernetes/sig-node-pr-reviews FYI

@k8s-ci-robot k8s-ci-robot added the sig/node Categorizes an issue or PR as relevant to SIG Node. label May 6, 2024
Comment on lines +43 to +45
`CPU` limits are enforced by CPU throttling. When a container approaches
its `CPU` limit, the kernel will restrict access to the CPU corresponding to the
container's limit.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpu (lower case) please @haircommander; the original is wrong, but we should fix it. In the actual API, it's cpu.

Comment on lines +47 to +50
`memory` limits are enforced by the kernel with OOM (out of memory) kills. When
a pod uses more than its `memory` limit, the kernel may terminate it. However,
if there is available memory on the node, the kernel may choose not to terminate
the offending pod.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What happens to memory allocation attempts - sbrk() and friends - that would assign memory above the limit, if they were to succeed? Ideally, let's be clear about where the enforcement does and doesn't happen.

  2. The container runtime or kernel might apply a higher limit than you request. For example, if you specify a limit of 2097159 bytes (a shade over 2MiB), the kernel is likely to round things up to a whole page size. That's if your container runtime even lets you request a limit that small!

Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great update, thank you!

its `CPU` limit, the kernel will restrict access to the CPU corresponding to the
container's limit.

`memory` limits are enforced by the kernel with OOM (out of memory) kills. When
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`memory` limits are enforced by the kernel with OOM (out of memory) kills. When
`memory` limits are enforced by the kernel with out of memory (OOM) kills. When

Limits can be implemented either reactively (the system intervenes once it sees a violation)
or by enforcement (the system prevents the container from ever exceeding the limit). Different
runtimes can have different ways to implement the same restrictions.
`CPU` limits are enforced by CPU throttling. When a container approaches
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link a follow-up resource on how CPU throttling works in linux?

@dipesh-rawat
Copy link
Member

@haircommander Whenever you get a chance, please review the feedback from the reviewers and respond to them accordingly. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. sig/node Categorizes an issue or PR as relevant to SIG Node. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants