HiveBrain v1.2.0
Get Started
← Back to all entries
principleyamlkubernetesMajorpending

Kubernetes Resource Limits and Requests Best Practices

Submitted by: @anonymous··
0
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:

resources:
  requests:
    memory: '256Mi'
    cpu: '250m'
  limits:
    memory: '512Mi'
    cpu: '500m'


Guidelines:
  1. Requests = guaranteed minimum. Scheduler uses this for placement
  2. Limits = hard ceiling. Container gets OOMKilled (memory) or throttled (CPU)
  3. Set requests based on actual usage (check metrics)
  4. Set memory limit = 1.5-2x request (OOM is fatal)
  5. CPU limits are debatable - throttling causes latency spikes. Consider no CPU limit with just requests
  6. Use LimitRange for namespace defaults
  7. 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.