Resource limits

Cap what one app or database may take from its server, memory, CPU, processes, files, disk.

Resource limits stop one runaway container from taking down its server and everything on it.

Settings -> Resources, on an app or a database.

  • Every limit is optional. Empty means no limit.
  • Each one becomes a key in the rendered Compose file, enforced by the kernel, so it applies on the next deploy, not on save.
  • On a Compose app they apply to each service of the stack, and a limit the service sets in its own file wins.

Memory and CPU

The size tiles with live usage and the suggested cap

Size sets memory and CPU at once: Nano (256 MB, 0.25 CPU), Micro (512 MB, 0.5), Small (1 GB, 1), Medium (2 GB, 2) or Large (4 GB, 4). No limit leaves it uncapped, and a size bigger than the server is greyed out.

FieldWhat it caps
Memory limitRAM, in MB. Over it, the container is killed and restarted.
CPU limitCores: 0.5 is half a core, 2 is two. Over it, the container is throttled.

With View monitoring, each field shows current use and the peak of the last 15 minutes. The suggested size is the smallest with 1.5x headroom over that peak: Apply fills it in. A cap below the peak is flagged before you save.

Save limits offers Deploy now (Redeploy now on a database). Clear all empties every field, advanced ones included.

A memory limit is a kill switch, not a throttle. Set it above the app's real peak, not at it, and watch Monitoring for a while before tightening.

Advanced limits

Advanced limits: processes, files and disk on top of memory and CPU
FieldWhat it caps
Memory reservationSoft floor: RAM kept free for it under contention. No higher than the memory limit.
Swap limitMemory plus swap. Needs a memory limit, and at least that much.
CPU sharesRelative weight, only under contention. Default 1024; 2048 gets twice the share.
CPU pinningCores it may run on: 0, 0,1 or 0-3.
Process limitProcesses and threads. The defence against a fork bomb.
Open filesFile descriptors (ulimit nofile). Raise it on "too many open files".
User processesPer-user processes (ulimit nproc).
Shared memory/dev/shm, 64 MB by default. Some databases and Chromium need more.
Disk quotaThe container's writable layer, not its volumes.
OOM priority-1000 to 1000. Higher is killed first when the host runs out of memory.

Important limits

  • Disk quota only works on some hosts: overlay2 on XFS with project quotas, or devicemapper. Anywhere else the deploy fails. Leave it empty unless you know the storage driver.
  • MySQL and MariaDB need about 512 MB. Less can send InnoDB into a restart loop. Their Resources page says so.
  • A container killed for memory looks like a crash. The logs end mid-work with no error, then it restarts. Dying at the same size every time is the tell.
  • CPU limit and CPU shares differ. A limit always applies; shares only matter on a busy machine.
  • A negative OOM priority needs the host-volumes grant. It asks the kernel to kill other containers first, so it is gated like a bind mount. See Host access.

Troubleshooting

  • The container is killed repeatedly: the memory limit is under its real peak. Raise it, or fix the leak.
  • The deploy fails on the storage option: the host does not support disk quotas. Clear that field.
  • The limits seem to do nothing: they were saved but not deployed. Redeploy.

More in Deploys and builds troubleshooting.

See also

Did this page help you?

On this page