mediumConceptScenarioMidSeniorStaff
What happens when a container hits its CPU limit, and what happens when it hits its memory limit?
Container CPU and memory limits fail differently: CPU limits throttle work, while memory limits can trigger OOMKilled restarts. Debug by comparing requests, limits, actual usage and runtime-specific memory settings. Use this containers answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects cgroups to the point an interviewer is testing.
5 min readUpdated 2026-08-15
Answer
Short answer
A container over CPU limit is throttled; a container over memory limit can be killed. Set requests from steady usage, limits from failure tolerance, and leave headroom for JVM, Node or native memory outside the heap.
Was this answer helpful?
Likely follow-ups
- Throttling is high but average CPU usage is 30% of the limit. How is that possible and what would you change?
- A container is OOM-killed and the process that died was not the one doing the allocating. Why can that happen?
- Why is setting a CPU limit equal to the request sometimes worse for latency than setting no limit at all?
- How would you size a memory limit for a JVM service, and what has to be true of the heap setting?
Related questions
- What is a container image, and why is a container not a virtual machine?mediumAlso on containers and cgroups5 min
- A pod is stuck in CrashLoopBackOff. How do you debug it?mediumAlso on oomkilled4 min
- Your .NET service keeps getting OOM-killed in its container while the GC reports a small heap. Where has the memory gone?hardAlso on containers6 min
- Two replicas of the same deployment are running different code, and both were started from the same image tag. How did that happen and what do you change?hardAlso on containers6 min