How Nginx Ingress calculates the worker_processes and worker_rlimit_nofile
This document (000020079) is provided subject to the disclaimer at the end of this document.
Situation
Question
How Nginx Ingress calculates the worker_processes and worker_rlimit_nofile
Answer
About the parameters;
worker_processes
This parameter determines the number of Nginx worker processes to spawn during startup.
worker_rlimit_nofile
This parameter controls the open file limit per worker process.
More details can be found on Nginx documentation
Both worker_processes
and worker_rlimit_nofile
are calculated dynamically by Nginx Ingress during startup.
Based on the source code of Ingress Nginx;
worker_processes = Number of CPUs ($ grep -c processor /proc/cpuinfo)
worker_rlimit_nofile = ( RLIMIT_NOFILE / worker_processes ) - 1024
where RLIMIT_NOFILE is the maximum allowed open files by the process ( ulimit -n
)
From Nginx Ingress shell, you can verify the same.
# kubectl exec -it -n ingress-nginx nginx-ingress-controller-8ln2b -- bash
bash-5.0$ ulimit -n
1048576
bash-5.0$
bash-5.0$ grep -c processor /proc/cpuinfo
2 <<---- worker_processes
bash-5.0$
bash-5.0$ echo $(((1048576/2)-1024))
523264 <<--- worker_rlimit_nofile
bash-5.0$
bash-5.0$ egrep "worker_processes|worker_rlimit_nofile" /etc/nginx/nginx.conf
worker_processes 2;
worker_rlimit_nofile 523264;
bash-5.0$
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020079
- Creation Date: 06-May-2021
- Modified Date:06-May-2021
-
- SUSE Rancher
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com