这里有一个简单的测试服务器:
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
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内存。
编辑
这里经过一番讨论和测试不同的东西,这似乎是从15000变化net.inet.tcp.msl到1000毫秒,使测试与AB高频Web服务器消失的问题。
sudo sysctl -w net.inet.tcp.msl=1000 # this is only good for local development
+1
你找不到原因?潜在的解释可能是操作系统将套接字保持在“最近使用”状态,并且不会在几分钟内重用它。显然,人们可以重新配置操作系统的IP层不这样做。 –
2012-09-16 08:12:47
+1
如果有帮助,我可以在我的MBP上重现这种确切的行为。 16359个请求完成。不知道是什么原因造成的。 –
2012-09-16 08:39:21
+1
嗯,想出来大声,这个数字是可疑接近16384 ... –
2012-09-16 08:42:41