Kubernetes resource requests and limits determine where pods can run, how much capacity a workload reserves, and what happens when a container needs more resources than expected. This guide explains how to size CPU and memory from observed usage, understand scheduling and quality of service behavior, tune HPA settings, and establish a recurring review process that reduces throttling, OOMKilled events, evictions, and unused capacity.
Overview
A resource request is the amount of CPU or memory Kubernetes uses when scheduling a pod. It represents the capacity the workload needs to be placed safely on a node. A limit is the maximum amount a container is allowed to consume, subject to the behavior of the resource and the runtime. Requests and limits are configured per container, so a pod's effective request or limit is the sum of its containers' values, excluding special init-container scheduling rules that may affect placement.
Requests and limits solve different problems. Requests influence scheduling and, in many clusters, resource-based autoscaling calculations. Limits constrain consumption. Setting a request too low can make a workload appear inexpensive to the scheduler or HPA while still experiencing contention. Setting it too high can leave allocatable capacity stranded and prevent other pods from being scheduled. A limit that is too low can cause CPU throttling or memory termination; a limit that is unnecessarily high can reduce the usefulness of capacity planning.
Start with a workload baseline rather than a copied value from another service. Measure normal traffic, expected peaks, startup behavior, batch activity, and deployment transitions. A web API, queue consumer, scheduled job, and stateful database have different resource shapes and should not share a generic sizing rule.
resources:
requests:
cpu: "250m"
memory: "256Mi"
limits:
cpu: "1"
memory: "512Mi"In this example, the scheduler reserves 250 millicores and 256 MiB for the container. The container may use more CPU up to its configured limit when capacity and runtime behavior permit, while memory growth beyond the limit can result in an OOMKilled termination. Exact outcomes also depend on node pressure, runtime behavior, and the rest of the pod specification.
What to track
Usage and saturation
For each workload, record CPU usage, memory working set or resident usage as exposed by your monitoring stack, restart count, termination reason, replica count, and pod placement. Examine percentiles over a meaningful window instead of relying only on an average. A monthly review may use several weeks of representative data; a newly launched service may need shorter, more frequent reviews until its traffic pattern stabilizes.
Track at least these questions:
- What are typical and peak CPU levels during normal traffic?
- Does memory rise gradually, remain stable, or change with batch size and cache behavior?
- Are containers being CPU-throttled when latency or queue depth increases?
- Have any containers restarted with an OOMKilled reason or other memory-related termination?
- Are pods pending because their requests cannot fit on available nodes?
- Do HPA replicas increase because demand is rising, or because the target and request values are poorly aligned?
Requests, limits, and quality of service
Compare usage with both requests and limits. A workload that regularly uses nearly all of its request may need a higher request, even if it remains below its limit. A workload with a high limit but a low request may be schedulable on nodes that cannot sustain its peak demand alongside neighboring pods.
Kubernetes quality of service classes are derived from resource configuration. A pod with CPU and memory requests and limits set, with matching values for each container, can receive Guaranteed classification. A pod with some resource configuration but not that fully matching pattern is generally Burstable. A pod without requests or limits is generally BestEffort. QoS classification is relevant during resource pressure, but it is not a substitute for measuring workload behavior or setting appropriate values.
Scheduling and node capacity
Use allocatable node capacity, not raw node capacity, when reviewing placement. System components and DaemonSets consume resources, and requests from existing pods affect what Kubernetes considers schedulable. If pods remain Pending with insufficient-resource events, compare their summed requests with available allocatable capacity. Increasing requests to solve one service's performance issue may require a capacity change or a better distribution strategy rather than a simple manifest edit.
HPA inputs
For resource utilization-based Horizontal Pod Autoscaling, utilization is commonly evaluated relative to the container's resource request. If CPU request is set far above observed need, the same absolute CPU usage produces a lower utilization percentage. If the request is set too low, the HPA can react aggressively or scale before the service is actually saturated. Confirm that the metrics pipeline, often using metrics-server for basic resource metrics, is reporting data and that the target reflects a meaningful operating point.
Cadence and checkpoints
Use a recurring review table for every production workload. The following worksheet is deliberately simple:
| Area | Record | Review question |
|---|---|---|
| CPU request | Current value and recent usage percentiles | Can the pod meet normal demand without sustained contention? |
| CPU limit | Current value and throttling signals | Is the limit causing latency or avoidable throttling? |
| Memory request | Baseline, peak, and growth pattern | Does the request cover representative high usage? |
| Memory limit | Peak usage, restarts, and termination reasons | Is there safe headroom without masking a leak? |
| HPA | Target, min/max replicas, scale events | Does scaling follow demand and service health? |
| Capacity | Pending pods, node pressure, utilization | Can the cluster place the requested replicas? |
For established services, review this information monthly or quarterly according to operational risk and change frequency. Review sooner after a major release, traffic-pattern change, node-pool change, runtime upgrade, or autoscaler adjustment. During a new service launch, inspect daily or after each significant load-test iteration until the baseline is credible.
Keep changes traceable. Record the observed window, the reason for the change, the old and new values, the expected effect, and a rollback condition. Apply resource changes through the same deployment workflow used for other configuration so that the live cluster does not drift from version-controlled manifests.
How to interpret changes
CPU throttling
CPU is compressible: when demand exceeds an enforced CPU limit, the container is generally throttled rather than terminated. Throttling is not automatically a problem, but it deserves attention when it coincides with increased request latency, queue depth, timeout rates, or failed health checks. First check whether the limit is unnecessarily restrictive. Then check whether the application is actually CPU-bound, whether concurrency is appropriate, and whether the request is large enough for the HPA target to represent real demand. Raising a limit without checking node capacity can move contention elsewhere.
OOMKilled and memory pressure
Memory is not compressible in the same way. A container that exceeds its memory limit may be terminated and restarted with an OOMKilled reason. Node-level memory pressure can also lead to eviction decisions. Separate an isolated spike from a steady increase: a leak, unbounded cache, oversized batch, or changed workload can require an application fix rather than a larger limit. Before increasing memory, inspect heap settings, concurrency, payload size, cache bounds, and recent release changes.
Requests that are too high
If actual usage is consistently far below requests and performance is healthy, the request may be reserving capacity that other workloads cannot use. Lower it gradually and observe scheduling, latency, throttling, and HPA behavior. Do not optimize only for average usage; preserve headroom for expected peaks and startup requirements.
HPA instability
Repeated scale-up and scale-down events can indicate a target that does not match application behavior, delayed metrics, insufficient stabilization settings, or requests that distort utilization. Compare HPA decisions with request rate, latency, queue depth, and error rate. CPU utilization alone may be a poor scaling signal for I/O-bound services. When possible, use an autoscaling signal that reflects demand while retaining resource metrics for capacity protection.
For a broader operational process, connect these findings to your SLO and error budget worksheet. Resource tuning should protect user-visible reliability, not merely produce attractive utilization graphs.
When to revisit
Recalculate resource values on a monthly or quarterly cadence, and immediately after changes that can alter workload shape. Revisit them when traffic volume or request mix changes, a new version changes memory or CPU behavior, a queue or batch size increases, pods move to a different node type, the cluster adds or removes capacity, or an HPA begins scaling unexpectedly.
Use a safe tuning loop:
- Define the workload and the observation window.
- Collect usage percentiles, saturation indicators, restarts, evictions, pending pods, and HPA events.
- Identify whether the issue is application behavior, resource configuration, node capacity, or metrics quality.
- Change one related value or policy at a time when practical.
- Roll out gradually and watch service health, not just resource consumption.
- Document the result and set the next review date.
Before a planned rollout, consult the Kubernetes deployment strategy guide and make sure the cluster can schedule both existing and replacement pods during the transition. For new teams, the platform onboarding playbook can help standardize manifests and ownership. The practical goal is not a permanent, perfect number. It is a documented estimate that is checked against evidence, adjusted when conditions change, and reviewed before resource problems become incidents.