Docker image uses ~2 GB idle on hosts with unlimited nofile (ERTS port table) #47
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The published v0.6.0 image (
git.knope.dev/jfro/fuzzy_catalog:0.6.0, indexsha256:821b85db…, same digest as0.6andlatest) sits at about 2.18 GiB RSS while idle on Docker hosts whose containerd/dockerd unit setsLimitNOFILE=infinity(e.g. Debian'sdocker.iopackage). A second BEAM in the container (bin/fuzzy_catalog rpc/eval, the normal way to run remote commands) gets OOM-killed on a 4 GB host (exit 137,OOMKilled=true).Not a security issue, but a large memory regression on common hosts.
Cause
On those hosts containers get
ulimit -n= 1073741816. ERTS sizes its port table from the file descriptor limit (port_limit134217727), so:erlang.memory(:system)is ~2.17 GB before the app does anything.Repro
-e ERL_MAX_PORTS=65536→{35542224, 65536}--ulimit nofile=65536:65536→{34828688, 65536}Fix
Set
ENV ERL_MAX_PORTS=65536in the Dockerfile runner stage (still overridable at runtime with-e ERL_MAX_PORTS=…) and note it in the README. Workaround for v0.6.0 until then: run with-e ERL_MAX_PORTS=65536or--ulimit nofile=65536:65536.Found by Nye while checking the published image.