Skip to content
Optimal Lab

DevOps · interactive

Requests, limits and OOM kills

Memory and CPU limits behave very differently. Go over the memory limit and the container is killed. Go over the CPU limit and it's only slowed down. This app leaks 40 MiB a minute.

Memory used, 30 minutes

Dashed: the 512 MiB limit. Red: OOMKilled, then restarted from scratch.

3 OOM kills in 30 minutes

One request needing 0.8 CPU-seconds

1.60 s (throttled)

Memory crosses 512 MiB 3× and the container is killed each time. CPU limit 0.5: requests take 1.60 s.

Memory limit

CPU limit

  1. 1

  2. 2

    Memory can't be taken back from a running process, so the kernel kills it: OOMKilled, exit code 137. A leak becomes a restart loop.

    A bigger limit only delays it; fix the leak.

  3. 3

  4. 4

In production

Tools and technologies

Requests and limits are enforced by the kernel through cgroups.

Not tied to one language — use these names when you search docs or design a system.