Kubernetes interview question · Most asked
What is the difference between resource requests and limits, and what are the QoS classes?
Summary
Requests are what the scheduler reserves and what the pod is guaranteed; limits are the maximum it may use. Exceeding the memory limit gets the container OOM-killed; exceeding the CPU limit gets it throttled. QoS classes follow from them: Guaranteed (requests equal limits for all containers), Burstable (some requests or limits set), BestEffort (none), and under node memory pressure BestEffort pods are evicted first.
Longer Answer
Practical guidance many teams follow: always set memory requests and limits (often equal, since memory cannot be throttled), always set CPU requests, and be careful with CPU limits, because CFS quotas throttle bursts in short periods and cause latency spikes even when the node has idle CPU. Size requests from observed usage (VPA recommendations, metrics), not guesses.
Namespaces can enforce defaults and caps with LimitRange and ResourceQuota.
Key Points
- Requests: scheduling and guarantees.
- Limits: memory OOM-kill, CPU throttling.
- Guaranteed, Burstable, BestEffort.
- Careful with CPU limits; size from metrics.
More most-asked Kubernetes questions
- ConfigMaps and Secrets: how do they differ, and how should secrets really be handled?
- How does the scheduler place pods? Explain resource requests, node affinity, taints and tolerations.
- Describe the Kubernetes architecture: what runs on the control plane and what runs on the nodes?
- How do rolling updates work in a Deployment, and how do you roll back?
- Explain the Service types: ClusterIP, NodePort, LoadBalancer, ExternalName and headless.
- What happens, step by step, when you run kubectl apply for a Deployment?
- Deployment, StatefulSet, DaemonSet, Job and CronJob: when do you use each?
- Liveness, readiness and startup probes: how do you configure them correctly?