nginx and multiple cpu

Denis F. Latypoff denis at gostats.ru
Wed Jan 13 18:32:34 MSK 2010


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:denis at gostats.ru




More information about the nginx mailing list