Interview Prep/DevOps Fundamentals/Containers & Kubernetes basics

What are resource requests and limits in Kubernetes?

BeginnerConceptContainers & Kubernetes basics
Answer

In one line: Requests are the CPU and memory a container is guaranteed and are used by the scheduler to place pods; limits are the maximum a container is allowed to use.

Example:

resources:
  requests:
    cpu: "250m"       # a quarter of a CPU core
    memory: "256Mi"
  limits:
    cpu: "1"
    memory: "512Mi"

Requests

  • The scheduler only places a pod on a node that has enough unreserved capacity for its requests.
  • Used by the Horizontal Pod Autoscaler to calculate utilisation percentages.

Limits

  • CPU over the limit → the container is throttled (slowed down), not killed.
  • Memory over the limit → the container is OOMKilled (killed and restarted). You'll see OOMKilled in kubectl describe pod.

QoS classes (based on requests and limits):

  1. Guaranteed — requests = limits for CPU and memory. Last to be evicted.
  2. Burstable — requests set lower than limits.
  3. BestEffort — nothing set. First to be evicted when a node runs short of memory.

Why setting them matters:

  • No requests → the scheduler packs too many pods on a node; they fight for resources.
  • Requests too high → wasted, expensive nodes sitting mostly idle.
  • Memory limit too low → constant OOMKills and restarts.
  • CPU limits too tight → throttling and slow responses (many teams set CPU requests but leave CPU limits generous or unset).

How to choose values:

  • Look at real usage in Prometheus/Grafana or kubectl top pods.
  • Use the Vertical Pod Autoscaler in recommendation mode.
  • Set memory limit with some headroom above normal peak usage.
  • Use LimitRange and ResourceQuota to enforce defaults and caps per namespace.

Tip for interviews: explain throttling vs OOMKill — it's a classic question and a common real-world issue.

All DevOps Fundamentals questions

More on Containers & Kubernetes basics