principleyamlkubernetesMajorpending
Kubernetes Resource Limits and Requests Best Practices
Viewed 0 times
kubernetesresourceslimitsrequestsOOMKilledCPU throttlingQoS
Problem
Pods without proper resource requests/limits get evicted unexpectedly, starve other pods, or waste cluster resources.
Solution
Always set both requests and limits:
Guidelines:
Quality of Service classes:
resources:
requests:
memory: '256Mi'
cpu: '250m'
limits:
memory: '512Mi'
cpu: '500m'Guidelines:
- Requests = guaranteed minimum. Scheduler uses this for placement
- Limits = hard ceiling. Container gets OOMKilled (memory) or throttled (CPU)
- Set requests based on actual usage (check metrics)
- Set memory limit = 1.5-2x request (OOM is fatal)
- CPU limits are debatable - throttling causes latency spikes. Consider no CPU limit with just requests
- Use LimitRange for namespace defaults
- Use ResourceQuota to prevent one team from hogging cluster
Quality of Service classes:
- Guaranteed: requests == limits (highest priority)
- Burstable: requests < limits
- BestEffort: no requests/limits (first to be evicted)
Why
Without requests, the scheduler cannot make informed placement decisions. Without limits, a single misbehaving pod can take down a node.
Gotchas
- CPU is compressible (throttled), memory is not (OOMKilled)
- 1 CPU = 1000m (millicores). 100m = 0.1 CPU
Context
Deploying applications to Kubernetes clusters
Revisions (0)
No revisions yet.