Ideal value for worker_processes on kubernetes

8/25/2021

Based on the documentation here, https://nginx.org/en/docs/ngx_core_module.html#worker_processes

The worker_processes is defined as the number of worker processes.

The optimal value depends on many factors including (but not limited to) the number of CPU cores, the number of hard disk drives that store data, and the load pattern. When one is in doubt, setting it to the number of available CPU cores would be a good start (the value “auto” will try to autodetect it).

Most of the guides recommend setting this value to the number of cores on the server or set to auto which itself sets it to the number of cores on the machine.

I'm running OpenResty on Kubernetes so when I check the number of CPU cores from inside the openresty pod, it returns me 8 which is the number of cores my physical machine (node) has. However, with CPU requests & limits on the k8s, all the 8 cores wouldn't be available for the pod.

So what should be worker_processes's value for shared CPUs in the case of Kubernetes?

Thanks!

-- Kshitij Joshi
kubernetes
nginx
nginx-config
nginx-reverse-proxy
openresty

0 Answers