-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-tune worker_processes ? #31
Comments
"worker_processes auto;" won't work as you think it should inside cgroups-controlled environment (such as docker or lxc or whatelse). nginx relies on sysconf(_SC_NPROCESSORS_ONLN) call to determine the number of available CPUs to spawn the workers accordingly. Unfortunately in cgroups this does not work and the number of CPUs is not changing whether you define a cpu subset or not. Easily checked: [thresh@centos7-tests] |
Thanks for the answer! Any other way to auto-tune it then? |
For now you can generate nginx configuration based on how many CPUs you want to throw at it. A better solution would be providing a patch for nginx so "worker_processes auto;" will take cpusets its currently bound to into account. |
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
Apparently using auto doesn't work well with docker: nginxinc/docker-nginx#31
For this reason is it better not to use nginx in a container? I see in /proc/cpu the docker container only has 1 cpu |
Since nginx can auto-tune now the
worker_processes
configuration parameter, I would suggest to useworker_processes auto;
instead ofworker_processes 1;
in /etc/nginx/nginx.confRationale: Docker manages resources using container restrictions and expects them to automatically adapt to the provided amount of CPU and memory.
But for non-docker environments, using only one thread is a safe default. So upstream developers provide it that way.
The text was updated successfully, but these errors were encountered: