How to limit nginx processes on kubernetes worker node?

10/26/2020

Changing worker_process to auto in nginx configuration letting nginx to use all available CPUs of node.

In case of pods where we are limiting nginx to use only 2 CPU, it is expected that setting worker_process will use only 2 CPU but instead of that it is using all available node CPU. Is this expected behaviour in case of pods?

-- Ankur7890
kubernetes

2 Answers

10/27/2020

When resource limits are defined, Kubernetes makes sure to provide only that limited quota of CPU and memory for the container.

A container cannot use more than its share of CPU time during this interval.

So, even if the container tries to use more; it will be restricted.

-- lkamal
Source: StackOverflow

6/7/2021

i think you can setup a nginx.conf from configmap, and set worker_process from there.

-- Pengfei.X
Source: StackOverflow