为什么在基准测试时,简单的Thin Server停止响应16500个请求? [英] Why does a simple Thin server stop responding at 16500 requests when benchmarking?

查看:114
本文介绍了为什么在基准测试时,简单的Thin Server停止响应16500个请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
"ab"程序在大量请求后冻结,为什么?

Possible Duplicate:
'ab' program freezes after lots of requests, why?

这是一个简单的测试服务器:

Here's a simple test server:

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内存.

It breaks down at around 16500. Why? How can I find out what's going on. Is it GC in ruby or is it something with number of available network sockets on an OS X machine. I have a MPB 2.5 Ghz 6G memory.

编辑

在这里进行了讨论并测试了各种东西之后,似乎将net.inet.tcp.msl从15000更改为1000ms使得使用ab测试高频Web服务器的问题消失了.

After some discussion here and testing various things, it seems like changing net.inet.tcp.msl from 15000 to 1000ms makes the problem of testing high frequency web servers with ab go away.

sudo sysctl -w net.inet.tcp.msl=1000 # this is only good for local development

请参阅参考问题以及该问题的答案. "ab"程序在大量请求后冻结,为什么?

See referenced question with the answer to this problem. 'ab' program freezes after lots of requests, why?

推荐答案

为清楚起见,我将在此处添加解决方案.在OS X上使用ab进行高频测试的正确解决方案是将"net.inet.tcp.msl"设置从15000ms更改为1000ms.这只能在开发箱上完成.

I'll add the solution here for claritys sake. The correct solution for managing to do high frequency tests with ab on os X is to change the 'net.inet.tcp.msl' setting from 15000ms to 1000ms. This should only be done on development boxes.

 sudo sysctl -w net.inet.tcp.msl=1000 # this is only good for local development

此答案是在此处的评论中完成良好的侦探工作后找到的,并且来自对一个非常相似的问题的回答,这里的答案是: https://stackoverflow.com/a/6699135/155031

This answer was found after the good detective work performed in the comments here and comes from an answer to a very similar question here's the answer: https://stackoverflow.com/a/6699135/155031

这篇关于为什么在基准测试时,简单的Thin Server停止响应16500个请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆