Kubernetes resource requests and limits determine where pods can run, how much capacity workloads reserve, and what happens when containers need more resources than expected. This guide provides a reusable sizing checklist, workload templates, troubleshooting paths for Pending pods, CPU throttling, OOMKilled containers, evictions, and autoscaling conflicts, plus a review process for keeping values aligned with real usage.
Overview
A resource request is the amount of CPU or memory Kubernetes uses when scheduling a pod. A resource limit is the maximum amount a container is allowed to consume for that resource. Requests influence placement; limits influence runtime enforcement.
| Setting | Primary purpose | If it is too low | If it is too high |
|---|---|---|---|
| CPU request | Reserves a scheduling baseline and contributes to capacity calculations | Pods may be placed on nodes with insufficient practical headroom; autoscaling signals may be distorted | Pods may remain Pending even when actual usage is low; node capacity is reserved inefficiently |
| CPU limit | Caps CPU consumption | CPU-bound containers can be throttled during demand spikes | Useful burst capacity may be restricted; an overly tight cap can increase latency |
| Memory request | Reserves scheduling capacity and affects eviction priority | Pods may be packed too densely or become more vulnerable during node pressure | Pods may be Pending because the scheduler cannot find a node with enough allocatable memory |
| Memory limit | Sets a container memory ceiling | Exceeding it can result in an OOMKilled container | Memory that is rarely used may be reserved inefficiently, depending on the workload and cluster policy |
CPU is compressible: a container can usually wait for a later CPU allocation when demand exceeds its available share. Memory is not compressible. When a node or container cannot obtain more memory, Kubernetes or the operating system must reclaim memory, evict a pod, or terminate a process. Treat memory limits as a safety boundary, not as a target for normal operation.
Start with measured behavior rather than a universal ratio. A request should cover normal expected usage with enough room for ordinary variation. A limit should reflect the workload's safe operating boundary and failure behavior. For latency-sensitive services, batch jobs, and memory-heavy applications, those decisions will be different.
Checklist by scenario
For a new stateless service
- Define the normal traffic range, expected concurrency, startup behavior, and a realistic peak or load-test scenario.
- Measure CPU and memory separately. Do not infer memory needs from CPU usage or assign both resources using the same percentage.
- Set requests for the baseline that must be available for acceptable performance. Include startup overhead if readiness depends on a short initialization phase.
- Set a memory limit above normal working-set usage, leaving room for temporary allocation spikes that are safe to absorb.
- Use a CPU limit only after confirming that its ceiling supports the service's latency and burst requirements. A low CPU limit can produce throttling even when the node has spare CPU.
- Test the manifest under representative load, then compare actual usage with both requests and limits.
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "1"
memory: "512Mi"
This is a starting template, not a recommendation for every service. Replace the values after observing the application under normal and peak conditions.
For a CPU-bound worker or batch job
- Size the CPU request around the throughput needed for the job to make progress predictably.
- Decide whether bursting is useful. A CPU limit can protect a shared cluster, but it can also extend job duration if it is too restrictive.
- Set a memory request based on the job's working set and a limit that prevents one failed or unusually large input from consuming the node.
- Check whether parallelism multiplies resource usage. Several worker processes can make a container's peak memory materially larger than its idle footprint.
resources:
requests:
cpu: "500m"
memory: "512Mi"
limits:
cpu: "2"
memory: "1Gi"
For a memory-sensitive service
- Measure the resident working set during warm-up, steady state, cache growth, and the largest supported request or dataset.
- Account for language runtime behavior, garbage-collection patterns, native allocations, buffers, and sidecar containers.
- Keep the memory request and limit close enough that the scheduler does not place the pod on a node that lacks practical headroom.
- Investigate memory growth before simply raising the limit. A higher limit can postpone an OOMKilled event without fixing a leak or unbounded cache.
resources:
requests:
cpu: "100m"
memory: "768Mi"
limits:
cpu: "500m"
memory: "1Gi"
When a pod is Pending
- Inspect pod events and the scheduler message.
- Compare the pod's requests with node allocatable capacity, not raw node capacity.
- Check taints, tolerations, node selectors, affinity rules, topology constraints, and available ephemeral storage.
- Look for inflated requests from a sidecar, init container, policy default, or admission webhook.
- Do not reduce requests blindly. Confirm that the workload can still meet its performance baseline, or add suitable capacity and revise placement constraints.
When a container is CPU throttled
- Confirm whether the container is hitting its CPU limit rather than merely receiving less CPU because the node is busy.
- Compare throttling with request latency, queue depth, throughput, and restart behavior.
- Check whether the limit is lower than the burst required by startup, garbage collection, encryption, compression, or request handling.
- Raise the limit, remove it where that is acceptable under your cluster controls, or improve the workload's CPU efficiency.
- Re-test under load. A larger limit is not automatically better if it permits noisy-neighbor behavior or causes capacity contention.
When a container is OOMKilled
- Confirm the termination reason and inspect the container's memory usage before the event.
- Determine whether the container exceeded its memory limit or whether the node experienced memory pressure.
- Check application logs, heap profiles, cache size, input size, concurrency, and recent configuration changes.
- Increase the limit only when the additional memory is available and the workload's behavior justifies it.
- Raise the request as well when the higher steady-state footprint must be reflected in scheduling and capacity planning.
When autoscaling behaves unexpectedly
Horizontal pod autoscaling commonly evaluates utilization relative to resource requests. If a CPU request is much larger than actual normal usage, utilization can appear low and scaling may occur later than expected. If it is too small, normal activity can look like sustained saturation and trigger unnecessary replicas. Validate the request against observed usage and inspect the autoscaler's target, stabilization behavior, and available metrics. For memory, confirm that scaling on memory is appropriate for the workload; memory growth may indicate a leak rather than demand that more replicas will solve.
What to double-check
Measure the complete pod
Review every container, including logging, proxy, metrics, and service-mesh sidecars. Init containers affect scheduling differently from long-running containers, so inspect how their requests are combined by the scheduler. Also check namespace-level defaults, quotas, limit ranges, and admission policies that may add or alter values.
Use percentiles, not only averages
An average hides startup bursts and rare but valid workload peaks. Review a time window that includes normal traffic, deployments, scheduled jobs, failovers, and load tests. Compare a high-use percentile with the service-level performance requirement, then leave an explicit margin for expected variation. Avoid treating one incident spike as the permanent baseline without investigating its cause.
Understand QoS and eviction consequences
Requests and limits contribute to a pod's quality-of-service classification. Pods with matching CPU and memory requests and limits can receive different treatment from pods with partial or missing settings during resource pressure. The practical consequence is important: resource configuration affects not only placement and runtime caps, but also how the workload competes when a node is under stress. Confirm the resulting classification with the cluster's behavior and policy rather than assuming every pod has equal protection.
Separate application capacity from node capacity
A pod can have a reasonable limit and still fail if the node pool has insufficient allocatable memory, restrictive topology rules, or too little headroom for system components. Review node allocatable resources, daemonsets, reserved capacity, pod density, and disruption requirements during capacity planning.
Validate observability
Metrics should distinguish requested, limited, and actually used CPU and memory. Pair resource metrics with application signals such as latency, errors, throughput, queue depth, restarts, and garbage-collection pauses. Metrics-server can support basic usage visibility and common autoscaling scenarios, while deeper diagnosis may require the cluster's broader monitoring stack.
Common mistakes
- Copying values between services: A web API, worker, and database proxy have different startup, concurrency, and memory profiles.
- Setting requests equal to observed idle usage: Idle measurements can understate the resources needed for normal traffic and deployments.
- Using limits as performance targets: A memory limit is a boundary, and a CPU limit may be enforced as throttling. Neither describes healthy steady-state usage.
- Raising memory limits without investigating growth: This may delay an OOMKilled event while increasing node-level risk.
- Ignoring sidecars and policy defaults: The deployed pod may not match the resource block in the application repository.
- Changing requests during an incident without recording the reason: Emergency changes should be followed by a measured review so temporary headroom does not become unexplained permanent capacity.
- Assuming autoscaling fixes bad sizing: More replicas cannot correct a memory leak, an oversized sidecar, or a CPU limit that throttles every replica.
When to revisit
Resource sizing is a recurring operational task, not a one-time manifest decision. Revisit requests and limits before seasonal planning cycles, after major traffic or data-volume changes, during node-pool and instance-type changes, and after runtime, framework, or sidecar upgrades. Review them after load tests, repeated OOMKilled events, sustained CPU throttling, evictions, unexplained Pending pods, or autoscaling behavior that does not match demand.
Use this short review checklist:
- Pull a representative usage window for each container.
- Mark normal, high, and exceptional usage separately.
- Compare requests with scheduling outcomes and autoscaling signals.
- Compare limits with throttling, OOMKills, latency, and restart data.
- Check node allocatable capacity, quotas, policies, and sidecars.
- Test the proposed values in a controlled rollout or load test.
- Record the evidence, expected workload range, and next review trigger in the service's deployment documentation.
Keep the final configuration close to measured behavior, but preserve deliberate headroom for known bursts and operational events. If you are investigating a broader cluster symptom, pair this review with a Kubernetes troubleshooting guide. For infrastructure changes, document the capacity assumptions alongside your deployment workflow so resource decisions remain understandable when the workload or cluster changes.