Pcornel
Browse topics
Options
Recent
Favorites
Containers · Technical reference

Resource Requests and Limits

Direct answer

Requests reserve CPU and memory for scheduling; limits cap usage. CPU over limit is throttled; memory over limit is OOM-killed. QoS classes (Guaranteed, Burstable, BestEffort) affect eviction.

When to use this

Use it when pods are Pending for resources, throttled or OOM-killed.

First 30 seconds

1. kubectl top pod vs requests/limits.

2. OOMKilled in lastState?

3. CPU throttling metrics (container_cpu_cfs_throttled_seconds_total).

4. Namespace quota: kubectl describe resourcequota.

5. Adjust and redeploy.

Operational verification

requests → scheduling; limits → cgroup enforcement → throttle/OOM

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Docker / containerd / Podman / Kubernetes / OCI-compatible platforms
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformDocker / containerd / Podman / Kubernetes / OCI-compatible platforms
Scope / prerequisiteUse it when pods are Pending for resources, throttled or OOM-killed.
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

2 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 How to verify Verify boundary

Compare kubectl top values with requests over a normal day. Check Last State for OOMKilled after restarts. Review throttling in container metrics before adding CPU limits.

Step 2 Common failures Narrow the fault

Requests set far above usage waste capacity and block scheduling. A memory limit close to normal use causes repeated OOM kills. Missing requests make Pods BestEffort and first to be evicted.

Key points

Set requests from observed usage (kubectl top, metrics). Memory limits protect nodes; many teams avoid CPU limits to prevent throttling. LimitRanges and ResourceQuotas set namespace defaults/caps.

Key checks
  • kubectl top pod — first check for this topic
  • kubectl get pods -o wide — pods, status, node, IP
  • kubectl describe pod <pod> — events and conditions
  • kubectl logs <pod> [-c <c>] [--previous] — container logs (incl. previous crash)
  • kubectl get events --sort-by=.lastTimestamp — recent cluster events
ReferenceWhat it is1 section · depth on demand

How it works

Requests determine the QoS class together with limits: Guaranteed (requests equal limits), Burstable or BestEffort. Under node memory pressure, BestEffort and Burstable Pods are evicted first. LimitRange and ResourceQuota set defaults and totals per namespace.

ReferenceImportant terms & boundaries3 sections · depth on demand

Requests vs limits

RequestLimit
CPUScheduling guarantee, share under contentionThrottling (CFS quota)
MemoryScheduling guaranteeOOMKill if exceeded
resources:
  requests: { cpu: 250m, memory: 256Mi }
  limits:   { memory: 512Mi }

Documented example, not captured output. Common advice: always set memory requests = limits for critical apps; be careful with CPU limits (throttling hurts latency). QoS classes: Guaranteed, Burstable, BestEffort. kubectl top pod shows usage.

In depth

Units

CPU 250m = a quarter of a core; memory 256Mi = 256 × 2²⁰ bytes (256M is 256 × 10⁶, slightly less).

What each setting does at runtime

RequestLimit
SchedulingNode must have this much unrequested capacityNot used
CPU at runtimeShare under contention (cpu.weight)Hard quota per 100 ms period (cpu.max) → throttling
Memory at runtimeProtects from eviction rankingHard cap (memory.max) → OOMKilled

QoS classes

ClassConditionEvicted under node pressure
GuaranteedEvery container has requests = limits for CPU and memoryLast
BurstableAt least one request or limit setMiddle, ranked by usage above request
BestEffortNothing setFirst

Worked sizing from observed usage

kubectl top pod -l app=api --containers
# api-6d…  api  180m  410Mi
kubectl get pod api-6d… -o jsonpath='{.status.containerStatuses[0].lastState.terminated.reason}'

A reasonable start: memory request ≈ normal working set, memory limit with headroom for peaks (for example 1.5×); CPU request ≈ typical usage. Many teams omit CPU limits for latency-sensitive services, because throttling hurts tail latency while the request already guarantees a fair share.

LimitRange sets defaults for containers that specify nothing; ResourceQuota caps the namespace total and requires every Pod to set the quota-controlled resources.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Common mistakes

  • Limits without requests, or CPU limits causing throttling.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
resource requests and limitskubernetes requests limitsoomkilled
Confirmation

Confirm action

Continue?