Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if a Kubernetes pod exceeds its cpu resources 'limit'?

Tags:

kubernetes

NAME                      CPU(cores)   MEMORY(bytes)   
apache-757ddfbc75-khhfw   10m          61Mi
like image 323
Shashank Omre Avatar asked Aug 22 '19 11:08

Shashank Omre


People also ask

What happens if pod exceeds CPU limit?

If a container attempts to exceed the specified limit, the system will throttle the container.

What is CPU limit in Kubernetes?

Each container has a limit of 0.5 CPU and 128MiB of memory.

Should I set CPU limits Kubernetes?

CPU limits on Kubernetes are an antipattern Many people think you need CPU limits on Kubernetes but this isn't true. In most cases, Kubernetes CPU limits do more harm than help.

What causes CPU throttling in Kubernetes?

CPU throttling occurs when you configure a CPU limit on a container, which can invertedly slow your applications response-time. Even if you have more than enough resources on your underlying node, you container workload will still be throttled because it was not configured properly.


2 Answers

k8s doc refer:

A Container might or might not be allowed to exceed its CPU limit for extended periods of time. However, it will not be killed for excessive CPU usage.

Most of those case, nothing will happen. CPU usage is very very flexible.

like image 52
Leo Avatar answered Dec 27 '22 09:12

Leo


It seems throttling occurs (this is NOT written in the official docs):

Kubernetes uses kernel throttling to implement CPU limit. If an application goes above the limit, it gets throttled (aka fewer CPU cycles). Memory requests and limits, on the other hand, are implemented differently, and it’s easier to detect. You only need to check if your pod’s last restart status is OOMKilled.

https://medium.com/omio-engineering/cpu-limits-and-aggressive-throttling-in-kubernetes-c5b20bd8a718#:~:text=Kubernetes%20uses%20kernel%20throttling%20to,last%20restart%20status%20is%20OOMKilled

like image 28
Cristian Avatar answered Dec 27 '22 10:12

Cristian