可能重复:
“ab”程序在大量请求后冻结,为什么?
这是一个简单的测试服务器:
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 附近崩盘。为什么?我怎样才能知道发生了什么。它是红宝石中的GC,还是OS X机器上具有可用网络套接字数量的东西。我有 MPB 2.5 Ghz 6G 内存。
编辑
经过这里的一些讨论并测试了各种东西,似乎将 net.inet.tcp.msl 从 15000 更改为 1000ms 使得使用 ab 测试高频 Web 服务器的问题消失了。
sudo sysctl -w net.inet.tcp.msl=1000 # this is only good for local development
请参阅参考问题以及此问题的答案。'ab' 程序在大量请求后冻结,为什么?