Kubernetes in production · mid
Requests, limits, CPU throttling, scheduling and the HPA
The scheduler uses requests, not real usage. Limits are enforced by cgroups, and CPU limits can throttle a service whose average CPU looks low. The HPA needs requests and a working metric.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Requests: what the scheduler reserves and each pod's share of CPU under contention. Limits: the hard ceiling. Over the CPU limit the container is throttled. Over the memory limit it is killed: OOMKilled, exit code 137.
- QoS classes: Guaranteed (requests equal limits for every container), Burstable and BestEffort. Under node memory pressure the kubelet evicts BestEffort first, then Burstable pods above their requests, Guaranteed last.
- OOMKilled is the kernel enforcing a container's memory limit. Eviction is the kubelet removing a pod because the node is short of resources.
- CPU limits use the CFS quota: for example 100 ms of CPU time per 100 ms period, summed over all threads. Many threads can use the quota in a short time and then wait. Averages hide it, p99 shows it.
- Proof: the ratio of throttled periods to total periods (container_cpu_cfs_throttled_periods_total over container_cpu_cfs_periods_total).
- Go 1.25 and later set GOMAXPROCS from the container CPU limit. Before that, Go used every node core, which drained the quota quickly. Fix older services by setting GOMAXPROCS or raising or removing the CPU limit.
- Pending pods: describe pod shows Insufficient cpu. Requests far above usage waste capacity. Check the node group maximum, instance quotas, zone rules and free pod IPs.
- The HPA computes desiredReplicas as ceil(currentReplicas times currentMetric divided by target), within min and max, with stabilisation (scale-down waits 300 seconds by default). A metric shown as <unknown> means metrics-server is down or pods have no CPU request.
The red pen
Common traps: mistake → fix
Mistake: A low CPU average means no CPU problem
Fix: throttling shows in p99 and throttle ratios.
Mistake: The scheduler uses real usage
Fix: it uses requests.
Mistake: The HPA scales on any slow service
Fix: it needs a request and the right signal, and maxReplicas high enough.
Easy to hard
Questions interviewers ask, easy to hard
- Explain requests and limits and the three QoS classes.
- OOMKilled or evicted: what is the difference?
- p99 is bad but CPU use is 40 percent of the limit. Are the team right?
- Pods are Pending during a sale. What do you check?
- The HPA did not scale in a spike. Why?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.