categories.containers-platform Intermediate

What is the difference between Resource Requests and Limits in Kubernetes? How do you configure them?

AI Practice

Requests vs Limits

Requests: The guaranteed resources a container will receive. The Scheduler uses this value to decide which node to place the Pod on.

Limits: The maximum resources a container can use. When exceeded:

  • CPU: throttled (rate-limited), container is NOT killed
  • Memory: triggers OOMKilled, container is forcibly terminated

Configuration Example

resources: requests: memory: "128Mi" cpu: "250m" # 250 millicores = 0.25 cores limits: memory: "256Mi" cpu: "500m"

QoS Classes

Based on requests/limits settings, Kubernetes automatically assigns a QoS class that determines eviction priority when resources are scarce:

QoS Class Condition Eviction Priority
Guaranteed requests == limits Last to be evicted
Burstable Has requests, limits > requests Medium
BestEffort No requests or limits set First to be evicted

HPA (Horizontal Pod Autoscaler)

Automatically adjusts replica count based on CPU/Memory utilization:

kubectl autoscale deployment myapp --cpu-percent=70 --min=2 --max=10

Best Practices

  • Always set requests and limits in production
  • Avoid setting limits.cpu too low, which causes throttling and performance issues
  • Use VPA (Vertical Pod Autoscaler) or tools like Goldilocks to find appropriate resource values

✦ AI Mock Interview

Type your answer and get instant AI feedback

Sign in to use AI scoring

Copyright © 2026 Wood All Rights Reserved · FE Interview Hub