Pods request 2 CPU and 4 GiB each but use 200m and 600 MiB. How do you right-size without causing OOMs?
IntermediateScenarioCost
Answer
Situation read → Teams over-request out of fear. Right-sizing must be based on real peaks, not averages, and must be rolled out carefully.
What I'd do →
- Measure over at least two weeks, including peak traffic:
quantile_over_time(0.95, rate(container_cpu_usage_seconds_total{namespace="shop",container="api"}[5m])[14d:5m])
max_over_time(container_memory_working_set_bytes{namespace="shop",container="api"}[14d])
- Set CPU request near p95 usage. Set memory request and limit from the max working set plus 20–30% headroom.
- Use VPA in
Off(recommendation) mode as a second opinion. - Roll out per service, watching OOMKilled counts, throttling and latency for a week.
- Make it continuous: a monthly report of the biggest gaps between request and usage.
Why → Memory is incompressible, so it's sized on peak; CPU is compressible, so slight under-sizing only causes throttling.
Interview tip → Use container_memory_working_set_bytes; it's what the kubelet uses for eviction and OOM decisions.
More on Cost
The AWS bill jumped 40% this month and finance wants an explanation by tomorrow. How do you find out why?BeginnerThe "NAT Gateway – data processed" line is $9,000 a month. How do you bring it down?IntermediateCut EKS compute cost by 40% without hurting reliability. What's your plan?AdvancedDev and test environments run 24/7 but are used only during office hours. How do you cut that cost?BeginnerCloudWatch Logs costs more than the EC2 fleet. What do you do?IntermediateFinance asks you to buy commitments. Savings Plans or Reserved Instances, and how much?Intermediate