Use it when pods are Pending for resources, throttled or OOM-killed.
Resource Requests and Limits
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.
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.
requests → scheduling; limits → cgroup enforcement → throttle/OOM
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
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.
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.
kubectl top pod— first check for this topickubectl get pods -o wide— pods, status, node, IPkubectl describe pod <pod>— events and conditionskubectl 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
| Request | Limit | |
|---|---|---|
| CPU | Scheduling guarantee, share under contention | Throttling (CFS quota) |
| Memory | Scheduling guarantee | OOMKill 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
| Request | Limit | |
|---|---|---|
| Scheduling | Node must have this much unrequested capacity | Not used |
| CPU at runtime | Share under contention (cpu.weight) | Hard quota per 100 ms period (cpu.max) → throttling |
| Memory at runtime | Protects from eviction ranking | Hard cap (memory.max) → OOMKilled |
QoS classes
| Class | Condition | Evicted under node pressure |
|---|---|---|
| Guaranteed | Every container has requests = limits for CPU and memory | Last |
| Burstable | At least one request or limit set | Middle, ranked by usage above request |
| BestEffort | Nothing set | First |
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.
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
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.