nginx 测试(三)

1.  测试环境

硬件:PC2台 (CORE I5 4核 + 4G DDR3 + 1Gb网卡)

千兆交换机一台:1000Mb交换机

OS:centos 5.6

测试工具:apache ab

nginx版本:nginx/1.0.9

测试压缩包:18MB zip文件一个/1.84MB  gz文件一个

2. 第一种参数配置

   a. nginx.conf

user  nginx;
worker_processes  4;
worker_cpu_affinity 0001 0010 0100 1000;
worker_rlimit_nofile 65535;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    use  epoll;
    worker_connections  65535;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    #aio             on;
    #directio        1M;
    #output_buffers  1 128K;
    sendfile        on;
    tcp_nopush      on;
    #open_file_cache max=1000 inactive=1d;
    #open_file_cache_valid    30s;
    #open_file_cache_min_uses 2;
    #open_file_cache_errors   on;
    keepalive_timeout  65;
    tcp_nodelay        on;
    #gzip  on;
    include /etc/nginx/conf.d/*.conf;
}
  b. default.conf

server {
    listen       80;
    server_name  localhost;
    location / {
        #aio             on;
        #directio        1K;
        #output_buffers  1 128K;
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    location /nginxstatus {
        stub_status on;
        access_log off;
    }
}
c. 测试一
[root@x ~]# ab -c 10 -n 100 http://172.20.127.202/a.zip
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 {1}gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.20.127.202 (be patient).....done


Server Software:        nginx/1.0.9
Server Hostname:        172.20.127.202
Server Port:            80

Document Path:          /a.zip
Document Length:        18200898 bytes

Concurrency Level:      10
Time taken for tests:   15.711915 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      1820111900 bytes
HTML transferred:       1820089800 bytes
Requests per second:    6.36 [#/sec] (mean)
Time per request:       1571.192 [ms] (mean)
Time per request:       157.119 [ms] (mean, across all concurrent requests)
Transfer rate:          113127.71 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   46  33.9     47     189
Processing:   183 1469 551.2   1449    6091
Waiting:        0   58  87.9     45     707
Total:        184 1516 563.5   1499    6280

Percentage of the requests served within a certain time (ms)
  50%   1499
  66%   1558
  75%   1566
  80%   1579
  90%   1609
  95%   2247
  98%   2323
  99%   6280
 100%   6280 (longest request)
  10并发、100请求、网卡90+%的利用率、总传输数据量1.8GB+,不错的性能。 同样的测试条件进行了几次,结果相差不大。

  d. 测试二

[root@x ~]# ab -c 100 -n 1000 http://172.20.127.202/a.zip
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 {1}gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.20.127.202 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests


Server Software:        nginx/1.0.9
Server Hostname:        172.20.127.202
Server Port:            80

Document Path:          /a.zip
Document Length:        18200898 bytes

Concurrency Level:      100
Time taken for tests:   156.345139 seconds
Complete requests:      1000
Failed requests:        1
   (Connect: 0, Length: 1, Exceptions: 0)
Write errors:           0
Total transferred:      18225143009 bytes
HTML transferred:       18224921567 bytes
Requests per second:    6.40 [#/sec] (mean)
Time per request:       15634.514 [ms] (mean)
Time per request:       156.345 [ms] (mean, across all concurrent requests)
Transfer rate:          113837.84 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  239 113.8    283     380
Processing:  1570 15012 4786.9  14714   74288
Waiting:        2  239 111.6    284     383
Total:       1585 15251 4793.4  15018   74648

Percentage of the requests served within a certain time (ms)
  50%  15018
  66%  15330
  75%  15484
  80%  15698
  90%  17475
  95%  20462
  98%  26187
  99%  33481
 100%  74648 (longest request)
  100并发、1000请求、网卡90+%的利用率、总传输数据量18GB+,不错的性能。 同样的测试条件进行了几次,结果相差不大。

e. 测试三

[root@x ~]# ab -c 1000 -n 10000 http://172.20.127.202/b.tar.gz
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 {1}gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.20.127.202 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests


Server Software:        nginx/1.0.9
Server Hostname:        172.20.127.202
Server Port:            80

Document Path:          /b.tar.gz
Document Length:        1935301 bytes

Concurrency Level:      1000
Time taken for tests:   166.234897 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      19377442816 bytes
HTML transferred:       19375149610 bytes
Requests per second:    60.16 [#/sec] (mean)
Time per request:       16623.490 [ms] (mean)
Time per request:       16.623 [ms] (mean, across all concurrent requests)
Transfer rate:          113834.61 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  221 738.3     43    9113
Processing:   989 16075 4635.9  16400   36280
Waiting:       25   76 111.2     43    3882
Total:       1030 16297 4696.0  16625   36311

Percentage of the requests served within a certain time (ms)
  50%  16625
  66%  18296
  75%  19362
  80%  20050
  90%  21870
  95%  23422
  98%  25373
  99%  26329
 100%  36311 (longest request)


3. 第二种参数配置

据说用linux的AIO可以很大的提高nginx的IO能力,所以有了下面的配置

a. nginx.conf

nginx.conf配置保持不变

b. default.conf

location / {
        aio             on;
        directio        1K;
        output_buffers  1 128K;
c. 测试一

[root@x ~]# ab -c 10 -n 100 http://172.20.127.202/a.zip
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 {1}gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.20.127.202 (be patient).....done


Server Software:        nginx/1.0.9
Server Hostname:        172.20.127.202
Server Port:            80

Document Path:          /a.zip
Document Length:        18200898 bytes

Concurrency Level:      10
Time taken for tests:   45.246391 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      1820111900 bytes
HTML transferred:       1820089800 bytes
Requests per second:    2.21 [#/sec] (mean)
Time per request:       4524.639 [ms] (mean)
Time per request:       452.464 [ms] (mean, across all concurrent requests)
Transfer rate:          39283.86 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.9      0      19
Processing:  1512 4440 1066.4   4434    6922
Waiting:       10   55  37.3     44     214
Total:       1512 4441 1066.4   4434    6922

Percentage of the requests served within a certain time (ms)
  50%   4434
  66%   4976
  75%   5136
  80%   5300
  90%   5769
  95%   6100
  98%   6605
  99%   6922
 100%   6922 (longest request)

10并发、100次请求、1.8GB+数据、网卡31+%利用率;进行了三次这个测试,测试结果很不稳定第一次45.25秒、第二次53.22秒、第三次38.66秒。

d. 测试二

[root@x ~]# ab -c 100 -n 1000 http://172.20.127.202/a.zip
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 {1}gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.20.127.202 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests


Server Software:        nginx/1.0.9
Server Hostname:        172.20.127.202
Server Port:            80

Document Path:          /a.zip
Document Length:        18200898 bytes

Concurrency Level:      100
Time taken for tests:   162.689609 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      18201119000 bytes
HTML transferred:       18200898000 bytes
Requests per second:    6.15 [#/sec] (mean)
Time per request:       16268.961 [ms] (mean)
Time per request:       162.690 [ms] (mean, across all concurrent requests)
Transfer rate:          109254.24 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   57  63.3     41     499
Processing:  9420 15617 1978.8  15643   31995
Waiting:        4  156 163.8     88    1164
Total:       9466 15674 1983.9  15691   32299

Percentage of the requests served within a certain time (ms)
  50%  15691
  66%  16313
  75%  16746
  80%  16961
  90%  17617
  95%  18055
  98%  19212
  99%  20561
 100%  32299 (longest request)
100并发、1000次请求、18GB+数据、网卡86+%利用率;进行了几次测试,测试结果均比较接近。

e. 测试三

[root@x ~]# ab -c 1000 -n 10000 http://172.20.127.202/b.tar.gz
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 {1}gt; apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.20.127.202 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Finished 10000 requests


Server Software:        nginx/1.0.9
Server Hostname:        172.20.127.202
Server Port:            80

Document Path:          /b.tar.gz
Document Length:        1935301 bytes

Concurrency Level:      1000
Time taken for tests:   166.665581 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      19365785920 bytes
HTML transferred:       19363493172 bytes
Requests per second:    60.00 [#/sec] (mean)
Time per request:       16666.559 [ms] (mean)
Time per request:       16.667 [ms] (mean, across all concurrent requests)
Transfer rate:          113472.13 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  181 648.4     42    9045
Processing:   981 16069 5055.2  16322   74670
Waiting:       32  117 199.9     44    3828
Total:       1029 16250 5092.1  16502   74729

Percentage of the requests served within a certain time (ms)
  50%  16502
  66%  18102
  75%  19172
  80%  19844
  90%  21639
  95%  23154
  98%  25134
  99%  26653
 100%  74729 (longest request)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值