2010年4月12日星期一

apache ab stress tool “apr_socket_recv: Connection reset by peer (104)” 的處理

使用apache 自帶的stresss tools ab, 如果併發設定的稍微大點就報錯了

類似:

[root@localhost bin]# ./ab -n 1000000 -c 2000 http://172.16.1.237/index.html

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.1.237 (be patient)

apr_socket_recv: Connection reset by peer (104)

Total of 80159 requests completed

開始懷疑是web server設置, os kernel parameter 設置的問題,後面發現不是, 而是ab 這個程序自身的問題,要打patch:

我用的是2.2.15 ,最新發佈的找到  srccode/support/ab.c

--修改代碼ab.c

   1367                 }

   1368                 return;

   1369             } else {

   1370                 //apr_err("apr_socket_recv", status); //原來的

   1371                 bad++;

   1372                 close_connection(c);

   1373                 return;

   1374             

   1375             }

   1376         }

   1377     }

make

使用這個新生成的ab做測試壓力可以達到20000

[root@localhost support]# ./ab -k -n 1000000 -c 20000 http://172.16.1.237/index.html

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.1.237 (be patient)

Completed 100000 requests

Completed 200000 requests

Completed 300000 requests

Completed 400000 requests

Completed 500000 requests

Completed 600000 requests

Completed 700000 requests

Completed 800000 requests

Completed 900000 requests

Completed 1000000 requests

Finished 1000000 requests

Server Software:        Apache/2.2.15

Server Hostname:        172.16.1.237

Server Port:            80

Document Path:          /index.html

Document Length:        62 bytes

Concurrency Level:      20000

Time taken for tests:   129.656 seconds

Complete requests:      1000000

Failed requests:        26877

   (Connect: 0, Receive: 8959, Length: 8959, Exceptions: 8959)

Write errors:           0

Keep-Alive requests:    982282

Total transferred:      344888716 bytes

HTML transferred:       61514602 bytes

Requests per second:    7712.75 [#/sec] (mean)

Time per request:       2593.110 [ms] (mean)

Time per request:       0.130 [ms] (mean, across all concurrent requests)

Transfer rate:          2597.69 [Kbytes/sec] received

Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:        0  128 1551.6      0   93118

Processing:     1  583 3610.3    260  104485

Waiting:        0  284 639.7    252   54667

Total:          1  711 4610.9    260  128455

Percentage of the requests served within a certain time (ms)

  50%    260

  66%    349

  75%    397

  80%    424

  90%    476

  95%    504

  98%    664

  99%  12202

100%  128455 (longest request)

[root@localhost support]#

[root@localhost support]# ./ab -k -n 1000000 -c 30000 http://172.16.1.237/index.html

/root/httpd-2.2.15/support/.libs/lt-ab: Invalid Concurrency [Range 0..20000]

Usage: /root/httpd-2.2.15/support/.libs/lt-ab [options] [http://]hostname[:port]/path

 

再次修改src code, grep 一下20000,將這個參數加大

但是無論如何也上不了 30000,

[root@localhost support]# ./ab -k -n 1000000 -c 30000 http://172.16.1.237/index.html

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.16.1.237 (be patient)

Test aborted after 10 failures

apr_socket_connect(): Cannot assign requested address (99)

 

有時間再查,記錄一下

没有评论:

发表评论