Skip to content
/
Suscribirse Subscribe

Detrás del telón hay sistemas, no magia. Arquitectura de software, IA y computación de bajo nivel para las trincheras de producción.

Behind the curtain there are systems, not magic. Software architecture, AI, and systems engineering from the production trenches.

🇪🇸 Cambiar a versión en español: Calculadora de Memoria, Heap y Límites Anti-OOMKill en Kubernetes

Right-size Kubernetes requests.memory, limits.memory, and runtime Heap ceilings (-Xmx / --max-old-space-size) to eliminate surprise OOMKilled (Exit Code 137) crashes and Linux CFS CPU throttling stalls.

Safe limits.memory1536 MiB
Safe Heap Ceiling (-Xmx / V8)1075 MiB
Native cgroup Reserve461 MiB
Anti-OOMKill Headroom30.0%
Safe QoS Guaranteed config: leaves native headroom before cgroup OOM kicks in.

  

cgroup v2 Accounting Formula & Non-Heap Overhead

Following Kubernetes Resource Management for Pods and Containers, Linux cgroups tracks total RSS + anonymous allocations + active page cache against limits.memory — not just language heap size:

Container Memory Budget = Observed Working Set × Non-Heap Multiplier + Multi-Worker Overhead + Spike Buffer

Safe Runtime Heap Cap = limits.memory × Safety Ratio (70% JVM, 75% Node.js, 85% Go GOMEMLIMIT)

Kubernetes QoS & Resource Limits Comparison

Config PatternQoS ClassNode Pressure BehaviorProduction Guidance
requests.memory == limits.memoryGuaranteedLast to be evicted by KubeletBest for critical APIs, caches, steady workloads
Set requests.cpu, omit limits.cpuBurstable (CPU)Zero artificial CFS 100ms quota throttling on idle coresPreferred for low P99 tail-latency web services
-Xmx equal to limits.memoryAnyExit Code 137 (OOMKilled) via Metaspace & stacksAnti-pattern: keep 20–30% native headroom

Frequently Asked Questions

Why do Kubernetes Pods die with OOMKilled (Exit Code 137) when JVM or Node heap still shows free space?

Linux cgroups counts everything inside the container namespace: JVM Metaspace, off-heap DirectByteBuffers, thread stacks (~1 MiB per thread), glibc arenas, and native C++ extensions. Setting heap size equal to limits.memory guarantees sudden kills under load.

Should I set strict limits.cpu on latency-sensitive microservices?

Not always. Linux CFS quota enforces CPU limits in 100ms slices; a short multi-threaded burst can exhaust a pod's quota in 15ms and freeze threads for the remaining 85ms even when node CPU sits idle.

Engineering Note: Client-side sizing calculator executed locally in your browser. Validate against real Prometheus container_memory_working_set_bytes metrics under load; see official Kubernetes Resource Management docs.
Suscribirse Subscribe