Requests, limits and QoS classes
What requests and limits really do: requests drive scheduling and CPU share, limits mean throttling or OOM kills, and how QoS classes decide who dies first.
Requests, limits and QoS classes
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A request is what the scheduler reserves on a node and what the container is guaranteed under contention. The scheduler only ever adds up requests, never actual usage or limits.
- A CPU limit is enforced by throttling (a CFS quota per 100 ms period). A memory limit is enforced by the kernel OOM-killing the container. CPU is compressible, memory isn't.
- Set only a limit and the API server copies it into the request. Set nothing and the container is BestEffort.
- QoS class follows from the resources: Guaranteed (requests equal limits for CPU and memory in every container), Burstable (some request or limit), BestEffort (none). It sets OOM-score and eviction order.
- Since 1.35 a running Pod's CPU and memory can be resized in place through the resize subresource, as long as its QoS class doesn't change.
Sharing a machine fairly
A node is a shared machine. Without rules, one Pod with a memory leak takes the node down, and a batch job pins every core while the web tier starves. And the scheduler has no way to know whether a node has room for another Pod.
Kubernetes gives each container two numbers per resource. A request is what the container needs: the scheduler reserves it, and the container gets at least that under contention. A limit is the most it may use. Think of a shared office kitchen fridge. Your request is the shelf with your name on it, guaranteed to be yours. The limit is how far you may spread onto empty shelves before someone stops you. The Linux cgroups lesson covers the kernel side; this one covers what Kubernetes does with it.
resources:
requests: {cpu: 250m, memory: 256Mi}
limits: {memory: 512Mi}
CPU is in cores (250m is a quarter of one). Memory is in bytes with binary suffixes (Mi, Gi). 256M is decimal megabytes, a classic typo.
Requests drive scheduling
The scheduler fits Pods by adding up requests, nothing else. On a lab cluster with two fake 4-CPU nodes, four small Pods on n1 brought its requests to 1750m, which kubectl describe node showed as cpu 1750m (43%). A Pod requesting 3 CPUs went to n2. A second one couldn’t fit anywhere, though no container was actually running:
0/2 nodes are available: 2 Insufficient cpu. preemption: 0/2 nodes are available: 2 No preemption victims found for incoming pod.
That’s the point to remember. Real usage and limits play no part. Requests set too high waste nodes, and requests set too low (or missing) pack nodes past what they can really sustain. Requests also matter at runtime: the CPU request becomes the container’s cpu.weight, its share when the node is busy.
Limits: throttle or kill
The two resources fail differently because one can be taken back and one can’t.
CPU is compressible. A CPU limit becomes a CFS quota: per 100 ms period, the container may use limit × 100 ms of CPU time. A multithreaded app can burn through that in a fraction of the period and then sit throttled until the next one starts. Average usage looks fine and latency spikes. That’s why many teams set CPU requests but no CPU limits: requests already guarantee fair shares under contention, and spare CPU stays usable.
Memory isn’t compressible. Memory can’t be taken back from a process without killing it. Exceed the memory limit and the kernel’s OOM killer ends the container (OOMKilled, exit code 137), and the kubelet restarts it. Always set a memory limit for anything that can leak, usually equal or close to the request. Memory QoS, beta since 1.37, can use cgroup v2’s memory.high to throttle before the hard kill, but its kubelet settings are off by default.
QoS classes
From the requests and limits of all containers, the API server derives a QoS class and writes it to status.qosClass:
| Class | Rule | OOM score adjustment |
|---|---|---|
| Guaranteed | every container has CPU and memory requests equal to limits | -997 |
| Burstable | at least one request or limit, not Guaranteed | 2 to 999, lower for bigger memory requests |
| BestEffort | no requests or limits at all | 1000 |
The adjustments are constants in the kubelet’s qos/policy.go. When the node runs out of memory, the kernel kills high scores first: BestEffort, then Burstable, Guaranteed last. The kubelet’s own eviction under memory pressure follows similar logic, starting with Pods using the most memory above their requests.
Our four lab Pods got Guaranteed, Burstable, BestEffort, and one surprise. A Pod with only limits: {cpu: "1", memory: 1Gi} came back Guaranteed with requests of cpu: 1, memory: 1Gi: when a request is missing, the API server copies the limit into it. That’s harmless for that Pod, and a surprise when a LimitRange adds default limits to a Pod that set none.
Guaranteed Pods also unlock the CPU manager’s static policy, which can give exclusive cores to containers with whole-number CPU requests, for latency-critical work.
Resizing in place
Resources used to be fixed for a Pod’s life. A plain update to them is still refused (pod updates may not change fields other than...), but since 1.35 in-place resize is GA through the Pod’s resize subresource:
kubectl patch pod guaranteed --subresource resize \
-p '{"spec":{"containers":[{"name":"app","resources":{"requests":{"cpu":"1"},"limits":{"cpu":"1"}}}]}}'
The API server accepted that. When we tried to lower the request below the limit on the same Guaranteed Pod, it refused: Pod QOS Class may not change as a result of resizing. The kubelet then applies the change to the cgroups, possibly with a container restart if resizePolicy says so, and reports progress through PodResizePending and PodResizeInProgress conditions. The vertical scaling lesson builds on this.
About the video
The embed is The Good Guy’s “All You Need to Know in 12 Minutes: Pods’ Requests and Limits in Kubernetes”, February 2023, 13 minutes. Its chapters cover why resource settings matter, planning them, units, how scheduling uses requests, limits, the application’s role, QoS classes, and CPU limits. That’s close to this lesson’s order. It predates in-place resize and Memory QoS. Judged from chapters, since transcripts can’t be fetched here, and from its “English (US) original” audio track. Shubham gour’s longer 2026 video in deeper demos an OOM kill.
What was run: against a local v1.37.3 control plane with two fake 4-CPU Nodes and no kubelet, we created the four QoS examples and read back their classes and defaulted requests, read the node’s allocated requests, watched the scheduler place one 3-CPU Pod and refuse the next with Insufficient cpu, and resized a Pod through the resize subresource, including the QoS-change refusal. Nothing ran, so throttling, OOM kills and cgroup values are from the docs and the v1.37.3 kubelet source, checked 2026-11-29.
Where this fits
Requests only help if people set them. Next: LimitRanges and ResourceQuotas.
Check yourself
A node has 4 CPUs and its Pods use 10 percent CPU, yet a Pod requesting 3 CPUs is Pending with 'Insufficient cpu'. Why?
The scheduler compares the new request with the sum of requests already on each node, not with real usage. If existing Pods request 1.75 CPUs, 3 more don't fit. Right-size requests (VPA recommendations or usage data) to fix it.
A latency-sensitive service has a CPU limit of 1 and uses only 0.4 CPU on average, but has p99 spikes. What might be going on?
CFS throttling. The quota is per 100 ms period, so a burst of multithreaded work can use the period's 100 ms of CPU time in 25 ms across four threads and then wait 75 ms. Averages look fine while requests stall. Many teams drop CPU limits and rely on requests for fairness.
A Pod spec sets limits cpu 1 and memory 1Gi and no requests. What QoS class is it?
Guaranteed. The API server defaults missing requests to the limits, so requests equal limits for both resources.
The node runs out of memory. Which containers does the kernel kill first?
BestEffort ones (oom_score_adj 1000), then Burstable ones, scored by how little they requested relative to node memory, and Guaranteed last (-997). The kubelet's own eviction under memory pressure also starts with Pods using the most above their requests.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.