accpet_mutex cause nginx worker balance problem

xinghua_hi nginx-forum at
Sun Aug 3 13:29:19 UTC 2014


      I use ab to test performance. but when i turn on accept_mutex,  I
found the num of connection for every nginx worker is not balance. for
I have 4 core and start 4 nginx worker.

ab -n 300000 -c 1000 -k "http://XXX/"

the establish connection of nginx worker 

(netstat -antp|grep ESTABLISHED|awk -F" " '{print $7}'|sort|uniq -c)

 644      24619/nginx:
  1         24620/nginx:
  53       24621/nginx:
 302      24622/nginx:

but when I turn off accept_mutex

 255      24660/nginx:
 358      24661/nginx:
 232      24662/nginx:
 155      24663/nginx:

so if my test app is cpu bound,  I will find one or two core of my 4 cpu are
very busy but other cores are very idle

I kown accept_mutex can control accept by turn and realize worker balance by
ngx_accept_disabled, but why " accpet_mutex off" seems control worker
balance more well ? when accept_mutex on ,  one or two worker can accept
connection much more than other.

thanks very much

Posted at Nginx Forum:,252241,252241#msg-252241

More information about the nginx mailing list