1

created an Nginx container with 4 static CPUs

docker run -tid --cpus 4 --cpuset-cpus 6,7,8,9 --net=host --name mynginx nginx docker exec -ti mynginx cat /etc/nginx/nginx.conf|grep worker_processes worker_processes auto; 

Assigned CPUs

taskset -acp 1426038 pid 1426038's current affinity list: 6-9 

Sending Traffic:

ab -n 10000000 -c 1000 http://172.16.91.5:80/ 

On top i can see that core 6 is used where as all the remaining cores are idle.

from top-Nginx Cores

 %Cpu6 : 14.6 us, 57.3 sy, 0.0 ni, 28.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu7 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu8 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu9 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st 

OS Cores

 %Cpu0 : 0.0 us, 2.8 sy, 0.0 ni, 32.1 id, 0.0 wa, 0.0 hi, 65.1 si, 0.0 st %Cpu1 : 0.0 us, 5.6 sy, 0.0 ni, 40.7 id, 0.0 wa, 0.0 hi, 53.7 si, 0.0 st %Cpu2 : 0.0 us, 0.9 sy, 0.0 ni, 29.9 id, 0.0 wa, 0.0 hi, 69.2 si, 0.0 st 

load average:

 34.84, 19.62, 8.36 

Any explanation to this behavior?

1 Answer 1

2

My guess is that nginx uses a hash of the client IP to select a worker from the pool. Since with ab all connections come from the same IP address, they all end up processed by single worker, therefore loading only one CPU core.

2
  • That's a great suggestion - @ananthan could try this by sending traffic from more client machines Commented Aug 23, 2022 at 18:26
  • 1
    Thanks for your suggestions. I have added one more client and repeated the test..but still all the remaining CPUs are idle.While load average shot up further. Commented Aug 24, 2022 at 10:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.