nginxにLion付属のab(ApacheBench)を実行したら失敗するときの解決ログ

nginxにab(ApacheBench)を実行すると失敗してた

うちのサーバは、さくらのVPSにてnginxがフロントにいて、そこから内側のapacheとかRackとかNodeに回しています。

そんなこのサーバにLion付属のabを実行すると失敗していましたが、自力でhttpdから httpd-2.4.1.tar.bz2を取得してmake。abだけ新しいのに差し替えましたら解決しました。

問題の確認から解決まで

まずは問題の発生している状態から。

apr_socket_recv: Connection reset by peer (54)

うーん? ただのgif画像とかでも同じように切られるのでapacheとかは無罪と判定。(静的ファイルの配信はnginxがしてるから)

% ab -n 100 -c 2 http://havelog.ayumusato.com/
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 havelog.ayumusato.com (be patient)...Send request failed!
apr_socket_recv: Connection reset by peer (54)
Total of 1 requests completed

バージョン確認

色々調べていたらnginxというよりもabのほうを新しくすれば解決するようなので試します。標準の状態だとRevision: 655654ですが、これを新しくします。

% ab -V
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/

新しめのhttpdを取得してmake

2.4.1を取得してきてmakeします。参考URLの通りの手順。

%wget http://apache.mirrors.pair.com//httpd/httpd-2.4.1.tar.bz2
%brew install pcre
%tar xzvf httpd-2.4.1.tar.bz2
%cd httpd-2.4.1
% ./configure
% make

abを上書き

できあがったabを、既存のabに上書きします。

% sudo cp support/ab /usr/sbin

Revision: 1178079 となりました。

% ab -V
This is ApacheBench, Version 2.3 <$Revision: 1178079 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

直った!

正常に実行されるようになりました。ab側の問題なのかnginxとの相性だったのか不明ですが、これでabを実行できるようになってめでたしめでたし。

% ab -c 2 -n 100 http://havelog.ayumusato.com/
This is ApacheBench, Version 2.3 <$Revision: 1178079 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking havelog.ayumusato.com (be patient).....done

Server Software:        nginx
Server Hostname:        havelog.ayumusato.com
Server Port:            80

Document Path:          /
Document Length:        29687 bytes

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        9   10   0.9     10      14
Processing:    37   53   9.8     52      89
Waiting:       33   48   8.9     46      81
Total:         47   63   9.7     62      98

Percentage of the requests served within a certain time (ms)
  50%     62
  66%     65
  75%     67
  80%     69
  90%     76
  95%     82
  98%     92
  99%     98
 100%     98 (longest request)

参考


Author

ahomuAyumu Sato

overflow, Inc.VPoE

東京資本で生きる名古屋の鳥類

Web 技術、組織開発、趣味など雑多なブログ。技術の話題は zenn にも分散して投稿しています。

Bio: aho.mu
X: @ahomu
Zenn: ahomu
GitHub: ahomu

Related

Latest

Archives

Tags

Search