AnythingOnline
🐳
Container Memory & CPU Limit Calculator Software & Web
100% Free • No Sign-Up

Container Memory & CPU Limit Calculator

Calculate Kubernetes Pod requests and limits, cgroup OOM kill headroom, and recommended runtime heap flags for Node.js and JVM containers.

Container Resources & Runtime Environment

cgroup hard limit (1024 MiB = 1 GiB)
Kubernetes scheduler reservation
1000m = 1.0 vCPU core
Guaranteed CPU shares (500m = 0.5 core)
Memory Headroom Buffer
-- MiB
Safety margin before kernel cgroup OOM kill
Kubernetes QoS Class
--
Memory Request Ratio
--%
Recommended Runtime Heap Sizing Flag
--
Leaves safety headroom for off-heap buffers and native overhead
Kubernetes Resource Manifest YAML
--

How Docker & Kubernetes Container Resource Sizing Works

Linux containers enforce resource constraints using control groups (cgroups). Configuring requests and limits properly is essential to prevent mysterious Out-of-Memory (OOM 137) process terminations and CPU throttling.

Understanding Requests vs. Limits

  • Memory Limit: Hard kernel memory ceiling. If container memory exceeds this limit, the Linux kernel OOM killer terminates the process immediately (Exit Code 137).
  • Memory Request: The minimum guaranteed memory reserved on a worker node by the Kubernetes scheduler.
  • OOM Safety Headroom: Headroom = Limit - Request.

Why Application Runtimes Need Heap Buffers

Runtimes like Node.js (V8 engine) and the JVM do not automatically restrict their total memory usage to the cgroup limit unless configured:

  • Node.js: V8 only controls the JavaScript old generation heap via --max-old-space-size. Off-heap allocations (Node.js Buffer instances, C++ modules, thread stacks) reside outside V8 heap. Setting heap size to ~75% of container limit leaves 25% for native buffers and OS overhead, avoiding OOM kills.
  • Java / JVM: Setting -XX:MaxRAMPercentage=75.0 leaves 25% of container RAM for Metaspace, GC worker threads, and direct bytecode memory buffers.

Frequently Asked Questions

What causes Exit Code 137 in Docker and Kubernetes?

Exit code 137 occurs when the Linux kernel sends SIGKILL (kill -9 = 128 + 9) because the container process consumed more memory than permitted by its cgroup memory.limit_in_bytes.

What is the difference between Guaranteed and Burstable QoS classes?

A Pod receives the Guaranteed QoS class when CPU and Memory requests exactly equal their respective limits for all containers. Burstable Pods have requests lower than limits, allowing them to burst when idle node capacity is available.

How does CPU limiting work in Linux cgroups?

CPU limits use the Completely Fair Scheduler (CFS) quota. For a 100ms period (100,000us), 1000 millicores grants 100,000us of runtime. If a multi-threaded app consumes this quota in 20ms, it is throttled for the remaining 80ms.