Skip to content

Commit

Permalink
Don't set ulimits (nproc)
Browse files Browse the repository at this point in the history
There is a not-insignificant performance overhead for all containers (if
containerd is a child of Docker, which is the current setup) if rlimits are
set on the main Docker daemon process (because the limits
propogate to all children).

We recommend using cgroups to do container-local accounting.

This applies the change added in 8db6109
to other init scripts.

Note that nfile cannot be set to unlimited, and the limit
is hardcoded to 1048576 (2^20) , see:
http://stackoverflow.com/a/1213069/1811501

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 13, 2016
1 parent 92b1577 commit 428d733
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion contrib/init/openrc/docker.initd
Expand Up @@ -13,7 +13,10 @@ start_pre() {
checkpath -f -m 0644 -o root:docker "$DOCKER_LOGFILE"

ulimit -n 1048576
ulimit -u 1048576

# Having non-zero limits causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
ulimit -u unlimited

return 0
}
2 changes: 1 addition & 1 deletion contrib/init/systemd/docker.service
Expand Up @@ -11,9 +11,9 @@ Type=notify
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
Expand Down
7 changes: 5 additions & 2 deletions contrib/init/sysvinit-debian/docker
Expand Up @@ -94,10 +94,13 @@ case "$1" in
chgrp docker "$DOCKER_LOGFILE"

ulimit -n 1048576

# Having non-zero limits causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
if [ "$BASH" ]; then
ulimit -u 1048576
ulimit -u unlimited
else
ulimit -p 1048576
ulimit -p unlimited
fi

log_begin_msg "Starting $DOCKER_DESC: $BASE"
Expand Down
6 changes: 5 additions & 1 deletion contrib/init/upstart/docker.conf
Expand Up @@ -2,8 +2,12 @@ description "Docker daemon"

start on (filesystem and net-device-up IFACE!=lo)
stop on runlevel [!2345]

limit nofile 524288 1048576
limit nproc 524288 1048576

# Having non-zero limits causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
limit nproc unlimited unlimited

respawn

Expand Down

0 comments on commit 428d733

Please sign in to comment.