Requests vs limits for CPU and memory?
resource management basics.
requests guide scheduling and reservation, limits cap usage; exceeding a CPU limit throttles the container, while exceeding a memory limit triggers an OOMKill since memory is incompressible.
WHAT THIS TESTS Whether you understand how Kubernetes schedules and enforces resources and the crucial difference between compressible and incompressible resources.
A GOOD ANSWER COVERS A request is the amount of CPU or memory a container is guaranteed; the scheduler uses the sum of requests to decide which node has room, and it reserves that amount. A limit is the maximum the container is allowed to use. The two need not be equal, and the gap allows bursting. The enforcement differs by resource type. CPU is compressible: if a container tries to exceed its CPU limit, the kernel CFS quota throttles it, so it simply runs slower, but it is never killed for CPU. Memory is incompressible: you cannot partially deny memory once allocated, so if a container exceeds its memory limit the kernel OOM killer terminates the process with an OOMKilled status, and the kubelet restarts the container per its restart policy. Requests also determine the Pod's QoS class, which affects who gets evicted under node pressure.
COMMON WRONG ANSWERS Saying exceeding a CPU limit kills the container. Saying exceeding a memory limit only throttles. Treating requests and limits as the same. Thinking the scheduler uses limits rather than requests for placement.
LIKELY FOLLOW-UPS How do requests determine QoS class? What is CFS throttling and how do you detect it? What does OOMKilled look like in kubectl describe? Why might you set memory request equal to limit?
ONE CONCRETE EXAMPLE A container with a 500m CPU limit doing heavy computation gets throttled and runs slower but stays up, while the same container with a 256Mi memory limit that allocates 300Mi is OOMKilled by the kernel and restarted, showing reason OOMKilled in its last state.
Read the original → kubernetes.io
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.