簡単なテスト サーバーを次に示します。
require 'rubygems'
require 'rack'
require 'thin'
class HelloWorld
def call(env)
[200, {"Content-Type" => "text/plain"}, "OK"]
end
end
Rack::Handler::Thin.run HelloWorld.new, :Port => 9294
#I've tried with these added too, 'rack.multithread' => true, 'rack.multiprocess' => true
テスト実行は次のとおりです。
$ ab -n 20000 http://0.0.0.0:9294/sdf
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 0.0.0.0 (be patient)
Completed 2000 requests
Completed 4000 requests
Completed 6000 requests
Completed 8000 requests
Completed 10000 requests
Completed 12000 requests
Completed 14000 requests
Completed 16000 requests
apr_poll: The timeout specified has expired (70007)
Total of 16347 requests completed
約 16500 で壊れます。なぜですか? どうすれば何が起こっているかを知ることができますか。ruby の GC ですか、それとも OS X マシンで利用可能なネットワーク ソケットの数に関するものですか。MPB 2.5 Ghz 6G メモリを使用しています。
編集
ここで議論し、さまざまなことをテストした結果、net.inet.tcp.msl を 15000 から 1000 ミリ秒に変更すると、ab を使用した高頻度 Web サーバーのテストの問題が解消されるようです。
sudo sysctl -w net.inet.tcp.msl=1000 # this is only good for local development
この問題への回答とともに、参照されている質問を参照してください。'ab' プログラムが多くのリクエストの後にフリーズするのはなぜですか?