Skip to content

Commit

Permalink
(fix) auto-tune worker_processes
Browse files Browse the repository at this point in the history
Addresses the fact that nginx uses 1 worker process by default as `auto` will not work correctly in a docker environment.  nginxinc/docker-nginx#31
  • Loading branch information
Archimedes Trjaano committed May 10, 2018
1 parent a5785a3 commit fa4b90a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ This container provides a nginx with LetsEncypt enabled. When tested with SSLLa
## NOTE

* On first initialization there will be no output for a while, this is because the DHPARAM generation takes quite a bit of time combined with the initial certificate generation.
* The `worker_processes` value is adjusted automatically to the number of available CPUs from *cgroup*, nginx official image hard codes it to `1`.
* Due to the nature of nginx and SSL certificates, it is not safe to run this configuration with multiple replicas especially when there are renewals. The `worker_processes` value is adjusted automatically to the number of available CPUs allocated though so it can handle more load.
2 changes: 2 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ fi
) 200>/etc/letsencrypt/lock

DOMAIN=$(echo $DOMAINS | cut -d ',' -f 1) envsubst < /etc/nginx/conf.d/default.conf.tmpl > /etc/nginx/conf.d/default.conf
NUMPROCS=$(cat /sys/fs/cgroup/cpuacct/cpuacct.usage_percpu | wc -w)
sed -i "s/worker_processes\\s\\+1;/worker_processes ${NUMPROCS};/" /etc/nginx/nginx.conf
crond
exec nginx -g "daemon off;"

0 comments on commit fa4b90a

Please sign in to comment.