# Nginx and multiple cpu

**URL:** <https://www.ruby-forum.com/t/nginx-and-multiple-cpu/181548>\
**Category:** NGINX\
**Created:** [January 13, 2010, 4:21pm UTC](https://www.ruby-forum.com/t/nginx-and-multiple-cpu/181548 "2010-01-13T16:21:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omer\_Faruk\_Sen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f17d59/32.png) [@Omer\_Faruk\_Sen](https://www.ruby-forum.com/u/Omer_Faruk_Sen)\
**Post date:** [January 13, 2010, 4:21pm UTC](https://www.ruby-forum.com/t/nginx-and-multiple-cpu/181548/1 "2010-01-13T16:21:05Z")

</div>

Hi,

I have a 8 core (4 core and HT enabled) machine to test nginx. In my  
configuration file

worker\_processes 8;

events {  
worker\_connections 30000;  
}

I have done a simple test on that 4 core here is mpstat -P ALL 1 output

05:08:35 PM CPU %user %nice %sys %iowait %irq %soft  
%steal %idle intr/s  
05:08:36 PM all 4.12 0.00 7.62 2.12 0.25 6.99  
0.00 78.90 12902.00  
05:08:36 PM 0 19.00 0.00 17.00 0.00 0.00 1.00  
0.00 63.00 1001.00  
05:08:36 PM 1 1.00 0.00 2.00 0.00 0.00 0.00  
0.00 97.00 0.00  
05:08:36 PM 2 1.00 0.00 4.00 6.00 0.00 0.00  
0.00 89.00 25.00  
05:08:36 PM 3 1.00 0.00 1.00 0.00 0.00 0.00  
0.00 98.00 0.00  
05:08:36 PM 4 7.92 0.00 23.76 0.00 0.00 1.98  
0.00 66.34 0.00  
05:08:36 PM 5 0.00 0.00 3.03 0.00 0.00 0.00  
0.00 96.97 1.00  
05:08:36 PM 6 0.99 0.00 2.97 9.90 0.00 0.00  
0.00 86.14 0.00  
05:08:36 PM 7 2.02 0.00 7.07 0.00 2.02 52.53  
0.00 36.36 11875.00

05:08:36 PM CPU %user %nice %sys %iowait %irq %soft  
%steal %idle intr/s  
05:08:37 PM all 1.75 0.00 5.24 1.00 0.12 6.74  
0.00 85.14 9524.24  
05:08:37 PM 0 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 1011.11  
05:08:37 PM 1 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:37 PM 2 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 7.07  
05:08:37 PM 3 2.97 0.00 7.92 0.00 0.00 0.00  
0.00 89.11 0.00  
05:08:37 PM 4 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:37 PM 5 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:37 PM 6 0.00 0.00 5.00 9.00 0.00 0.00  
0.00 86.00 0.00  
05:08:37 PM 7 10.89 0.00 28.71 0.00 0.99 53.47  
0.00 5.94 8504.04

05:08:37 PM CPU %user %nice %sys %iowait %irq %soft  
%steal %idle intr/s  
05:08:38 PM all 2.75 0.00 5.25 0.00 0.12 7.00  
0.00 84.88 8087.13  
05:08:38 PM 0 8.91 0.00 10.89 0.00 0.00 0.99  
0.00 79.21 991.09  
05:08:38 PM 1 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:38 PM 2 0.00 0.00 2.00 0.00 0.00 0.00  
0.00 98.00 0.00  
05:08:38 PM 3 3.00 0.00 7.00 0.00 0.00 0.00  
0.00 90.00 0.00  
05:08:38 PM 4 2.00 0.00 5.00 0.00 0.00 0.00  
0.00 93.00 0.00  
05:08:38 PM 5 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.99  
05:08:38 PM 6 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:38 PM 7 7.00 0.00 17.00 0.00 1.00 55.00  
0.00 20.00 7095.05

05:08:38 PM CPU %user %nice %sys %iowait %irq %soft  
%steal %idle intr/s  
05:08:39 PM all 1.12 0.00 3.62 0.00 0.12 7.86  
0.00 87.28 9617.00  
05:08:39 PM 0 1.00 0.00 0.00 0.00 0.00 0.00  
0.00 99.00 1001.00  
05:08:39 PM 1 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:39 PM 2 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:39 PM 3 2.00 0.00 7.00 0.00 0.00 1.00  
0.00 90.00 0.00  
05:08:39 PM 4 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:39 PM 5 0.00 0.00 0.00 0.00 0.00 0.00  
0.00 100.00 0.00  
05:08:39 PM 6 0.00 0.00 1.00 0.00 0.00 0.00  
0.00 99.00 0.00  
05:08:39 PM 7 6.06 0.00 21.21 0.00 1.01 62.63  
0.00 9.09 8617.00

As you can see nginx only use one core not all of them even if I state  
worker\_processes 8;

I have used nginx-0.7.64 and used centos 5.4 compiled using just  
./configure && make && make install. I have read that nginx supports  
multiple cpu but as far as I see from mpstat output it doesn’t  
Can anyone englighten me about that?

Regards.

---

<div class="post-metadata">

**Author:** ![Omer\_Faruk\_Sen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f17d59/32.png) [@Omer\_Faruk\_Sen](https://www.ruby-forum.com/u/Omer_Faruk_Sen)\
**Post date:** [January 13, 2010, 4:31pm UTC](https://www.ruby-forum.com/t/nginx-and-multiple-cpu/181548/2 "2010-01-13T16:31:37Z")

</div>

On 01/13/2010 04:20 PM, Omer Faruk Sen wrote:

> 

[SNIP]

> As you can see nginx only use one core not all of them even if I state  
> worker\_processes 8;
> 
> I have used nginx-0.7.64 and used centos 5.4 compiled using just  
> ./configure&& make&& make install. I have read that nginx supports  
> multiple cpu but as far as I see from mpstat output it doesn’t  
> Can anyone englighten me about that?

I’ve seen someting similar during my tests on an 8 core system (no HT).  
I  
set up a default nginx with and increased the number of worker processes  
to  
two but when I put load on nginx only one CPU gets used while the other  
stays idle.

Regards,  
Dennis

---

<div class="post-metadata">

**Author:** ![Omer\_Faruk\_Sen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f17d59/32.png) [@Omer\_Faruk\_Sen](https://www.ruby-forum.com/u/Omer_Faruk_Sen)\
**Post date:** [January 13, 2010, 4:33pm UTC](https://www.ruby-forum.com/t/nginx-and-multiple-cpu/181548/3 "2010-01-13T16:33:23Z")

</div>

Hello Omer,

Wednesday, January 13, 2010, 9:20:21 PM, you wrote:

> Hi,

> I have a 8 core (4 core and HT enabled) machine to test nginx. In my  
> configuration file

> worker\_processes 8;

> events {  
> worker\_connections 30000;  
> }

> I have done a simple test on that 4 core here is mpstat -P ALL 1 output

> 05:08:35 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s  
> 05:08:36 PM all 4.12 0.00 7.62 2.12 0.25 6.99 0.00 78.90 12902.00  
> 05:08:36 PM 0 19.00 0.00 17.00 0.00 0.00 1.00 0.00 63.00 1001.00  
> 05:08:36 PM 1 1.00 0.00 2.00 0.00 0.00 0.00 0.00 97.00 0.00  
> 05:08:36 PM 2 1.00 0.00 4.00 6.00 0.00 0.00 0.00 89.00 25.00  
> 05:08:36 PM 3 1.00 0.00 1.00 0.00 0.00 0.00 0.00 98.00 0.00  
> 05:08:36 PM 4 7.92 0.00 23.76 0.00 0.00 1.98 0.00 66.34 0.00  
> 05:08:36 PM 5 0.00 0.00 3.03 0.00 0.00 0.00 0.00 96.97 1.00  
> 05:08:36 PM 6 0.99 0.00 2.97 9.90 0.00 0.00 0.00 86.14 0.00  
> 05:08:36 PM 7 2.02 0.00 7.07 0.00 2.02 52.53 0.00 36.36 11875.00

> 05:08:36 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s  
> 05:08:37 PM all 1.75 0.00 5.24 1.00 0.12 6.74 0.00 85.14 9524.24  
> 05:08:37 PM 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 1011.11  
> 05:08:37 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:37 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 7.07  
> 05:08:37 PM 3 2.97 0.00 7.92 0.00 0.00 0.00 0.00 89.11 0.00  
> 05:08:37 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:37 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:37 PM 6 0.00 0.00 5.00 9.00 0.00 0.00 0.00 86.00 0.00  
> 05:08:37 PM 7 10.89 0.00 28.71 0.00 0.99 53.47 0.00 5.94 8504.04

> 05:08:37 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s  
> 05:08:38 PM all 2.75 0.00 5.25 0.00 0.12 7.00 0.00 84.88 8087.13  
> 05:08:38 PM 0 8.91 0.00 10.89 0.00 0.00 0.99 0.00 79.21 991.09  
> 05:08:38 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:38 PM 2 0.00 0.00 2.00 0.00 0.00 0.00 0.00 98.00 0.00  
> 05:08:38 PM 3 3.00 0.00 7.00 0.00 0.00 0.00 0.00 90.00 0.00  
> 05:08:38 PM 4 2.00 0.00 5.00 0.00 0.00 0.00 0.00 93.00 0.00  
> 05:08:38 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.99  
> 05:08:38 PM 6 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:38 PM 7 7.00 0.00 17.00 0.00 1.00 55.00 0.00 20.00 7095.05

> 05:08:38 PM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s  
> 05:08:39 PM all 1.12 0.00 3.62 0.00 0.12 7.86 0.00 87.28 9617.00  
> 05:08:39 PM 0 1.00 0.00 0.00 0.00 0.00 0.00 0.00 99.00 1001.00  
> 05:08:39 PM 1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:39 PM 2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:39 PM 3 2.00 0.00 7.00 0.00 0.00 1.00 0.00 90.00 0.00  
> 05:08:39 PM 4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:39 PM 5 0.00 0.00 0.00 0.00 0.00 0.00 0.00 100.00 0.00  
> 05:08:39 PM 6 0.00 0.00 1.00 0.00 0.00 0.00 0.00 99.00 0.00  
> 05:08:39 PM 7 6.06 0.00 21.21 0.00 1.01 62.63 0.00 9.09 8617.00

> As you can see nginx only use one core not all of them even if I state  
> worker\_processes 8;

> I have used nginx-0.7.64 and used centos 5.4 compiled using just  
> ./configure && make && make install. I have read that nginx supports  
> multiple cpu but as far as I see from mpstat output it doesn’t  
> Can anyone englighten me about that?

It’s just because one worker is able (at least kernel decided so) to  
process all requests. Try to play with ‘accept\_mutex on|off’ in nginx  
config.

> Regards.

–  
Best regards,  
Denis [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Omer\_Faruk\_Sen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/f17d59/32.png) [@Omer\_Faruk\_Sen](https://www.ruby-forum.com/u/Omer_Faruk_Sen)\
**Post date:** [January 14, 2010, 12:22pm UTC](https://www.ruby-forum.com/t/nginx-and-multiple-cpu/181548/4 "2010-01-14T12:22:49Z")

</div>

Hi,

Have enabled accept\_mutex on;

user root;  
worker\_processes 8;

worker\_rlimit\_nofile 32000;

#pid logs/nginx.pid;

events {  
accept\_mutex on;  
worker\_connections 30000;  
}

but still only one cpu is busy while others stay in idle mode? Any  
sugggestions?

Regards.
