AWS Builder Center
60% Free Memory, Yet Pods Were Dying: The Kubernetes Paradox

60% Free Memory, Yet Pods Were Dying: The Kubernetes Paradox

Our Kubernetes cluster had 60% free memory, yet pods were getting OOMKilled and users were seeing outages. The culprit wasn't a lack of infrastructure—it was resource fragmentation, and fixing it cut costs too.

"Our Kubernetes cluster had 60% free memory, yet users were seeing outages."
Sounds impossible?
That's exactly what I recently observed in a Java microservices environment running on Kubernetes.
Every microservice had:
  • ✅ Multiple replicas
  • ✅ CPU and Memory requests & limits configured
  • ✅ Plenty of spare capacity on the EC2 worker nodes
Yet, individual pods were getting OOMKilled, causing intermittent failures and impacting application availability.
At first glance, it looked like a lack of infrastructure.
It wasn't.
The real problem was resource fragmentation.
One pod would exceed its memory limit and be terminated, while neighboring pods—and even the EC2 node itself—still had gigabytes of unused memory.
Imagine this:
Node Memory: 32 GB

Pod A Uses 300 MB / Limit 2 GB
Pod B Uses 250 MB / Limit 2 GB
Pod C Uses 1.9 GB / Limit 2 GB
Pod D Uses 2.1 GB / Limit 2 GB ❌ OOMKilled

Node Memory Used: 10 GB
Node Memory Free: 22 GB
The cluster has plenty of free memory.
But Kubernetes enforces limits per pod, not per node.
A pod can't borrow unused memory from its neighbors.
The result?
  • Pods restart
  • Requests fail
  • Availability drops
  • Infrastructure still looks underutilized
And here's the part most teams miss—there's a hidden cost problem sitting right next to the availability problem.
Kubernetes schedules pods based on requests, not actual usage.
So when Pod A requests 2 GB but uses only 300 MB, that 1.7 GB is reserved on the node—unusable by other pods, yet fully paid for on your EC2 bill.
Multiply that across hundreds of pods and you get:
  • Nodes that look "full" to the scheduler while sitting at 30% real utilization
  • Cluster Autoscaler spinning up new EC2 instances that you don't actually need
  • A cloud bill that grows with your requests, not your workload
In other words: you're paying for memory that protects no one and serves nothing.
What usually causes it?
  • Overestimated CPU and memory requests ("let's keep 2 GB just to be safe")
  • Conservative resource limits that don't reflect real usage
  • Copy-pasted resource configs across services with very different profiles
  • Uneven traffic distribution across replicas
  • Memory spikes from specific API calls
  • JVM heap sizing that leaves little room for native memory
  • Autoscaling based only on CPU while memory becomes the bottleneck
The solution isn't "add more EC2 instances."
It's right-sizing—and done well, it fixes availability and cost at the same time.
Some approaches that can make a significant difference:
✔️ Continuously analyze actual CPU and memory usage per service (P50, P95, and peak—not just averages).
✔️ Use tools like the Vertical Pod Autoscaler (recommendation mode), Goldilocks, or Kubecost to identify the gap between requested and actually used resources.
✔️ Track the requests vs. usage ratio as a cost KPI. If your cluster requests 100 GB but uses 35 GB, that gap is your optimization opportunity.
✔️ Right-size in both directions: shrink requests for over-provisioned services, and increase limits for the handful of services that genuinely need more headroom.
✔️ Scale horizontally based on both CPU and memory, where it makes sense.
✔️ Tune JVM heap settings ( -Xmx ) to leave headroom for native memory—an OOMKill from native memory pressure looks identical to a heap problem on your dashboard, but the fix is different.
✔️ Revisit node instance types after right-sizing. Smaller, better-packed pods often mean fewer or cheaper EC2 instances—and open the door to Spot instances or Savings Plans for predictable workloads.
✔️ Monitor GC behavior, memory growth, and OOMKilled events before they impact users.
✔️ Build observability that correlates request traces, JVM metrics, Kubernetes events, and infrastructure metrics instead of looking at them in isolation.
The interesting part?
In the environments I've seen, right-sizing typically frees up 30–50% of reserved capacity. That translates directly into fewer worker nodes, a smaller EC2 bill, and—counterintuitively—better availability, because the services that actually need memory finally get it.
Availability and cost optimization are usually treated as competing goals.
With right-sizing, they're the same exercise.
Sometimes the biggest bottleneck isn't the amount of infrastructure you have.
It's how efficiently it's allocated—and how much of it you're paying for without using.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article