mirror of
https://github.com/nginx/nginx.git
synced 2026-07-10 10:54:57 +00:00
With 'worker_processes auto;' the number of worker processes to create is generally determined at runtime via sysconf(_SC_NPROCESSORS_ONLN); However this value does not take into account any restrictions that have been put in place via mechanisms like cpuset(7)'s and/or sched_setaffinity(2). So for example while a system may have 18 "cpus" available as returned via sysconf(_SC_NPROCESSORS_ONLN) the actual number of allowed to run on cpus may be much lower. E.g. On a 18 core system, with 'worker_processes auto;' nginx will create 18 worker processes (+ the master). E.g. $ pgrep -c nginx 19 If however nginx has been restricted to run on just four. We will still create 18 worker processes. E.g. $ taskset -a -c 0-3 ./sbin/nginx -c conf/minimal.conf $ pgrep -c nginx 19 This can happen for example with 'docker --cpuset-cpus=', where you may end up with many more worker processes than runnable cpus. This commit uses sched_getaffinity() (where available, at least Linux & FreeBSD) to determine the number of actual available runnable cpus. So in the above example we now get $ taskset -a -c 0-3 ./sbin/nginx -c conf/minimal.conf $ pgrep -c nginx 5 Four worker processes plus the master. Closes: https://github.com/nginx/nginx/issues/855 |
||
|---|---|---|
| .. | ||
| core | ||
| event | ||
| http | ||
| misc | ||
| os | ||
| stream | ||