Answers:
ab -n 200 -c 20 -r http://localhost
并且得到了(上帝禁止评论中有换行符!) Test aborted after 10 failures apr_socket_connect(): Operation already in progress (37) Total of 4 requests completed
这是由于Lion随附的Apache软件中的错误。最新版本的Apache(测试版)解决了该问题。要修复Ab,请按以下步骤操作:
下载最新版本的Apache
$ wget http://apache.mirrors.pair.com//httpd/httpd-2.3.16-beta.tar.bz2
如果无法使用2.3.16,请访问http://apache.mirrors.pair.com/httpd并获取最新版本
安装pcre(为此您需要brew)
$ brew install pcre
构建Apache
$ tar xzvf httpd-2.3.16-beta.tar.bz2
$ cd httpd-2.3.16-beta
$ ./configure
$ make
用新建的a覆盖现有的ab
$ sudo cp support/ab /usr/sbin
make
http时,我得到:未定义的符号:“ _apr_file_link”,引用自:rotationlogs.o中的_post_rotate ld:找不到符号collect2:ld返回1退出状态make [2]:*** [rotatelogs]错误1 make [1]:*** [全递归]错误1使:*** [全递归]错误1任何提示如何解决呢?
Connection reset by peer (54)
任何ab
基准测试的。然后在完成上述修复后,我可以做ab -n 100 -c 100
。那我就可以做ab -n 200 -c 100
。我可以做ab -n 200 -c 150
...当我-c
超过时-c 200
,有时会执行,有时会抛出Connection Reset by Peer (54)
错误。这是不确定的。该怎么办?
./configure
,如果您遇到以下内容,请查看一下此帖子configure: error: C compiler cannot create executables
:stackoverflow.com/a/11712497/599391
在此链接中使用通过自制程序更新ab的方法对我有用。
brew install 'https://raw.github.com/simonair/homebrew-dupes/e5177ef4fc82ae5246842e5a544124722c9e975b/ab.rb'
brew test ab
Error: Download failed: http://www.apache.org/dist/httpd/httpd-2.4.2.tar.bz2
brew install "https://raw.githubusercontent.com/simonair/homebrew-dupes/e26f111d450d1a030515e1dde4e1dc4693efa78d/ab.rb")
您是否尝试使用:127.0.0.1
而不是localhost?
另外,如果我不在http://
前面写url,我的ab也会失败。
我在Mountain Lion ab v2.3上遇到了相同的错误,并且几乎准备按照上述答案之一的指示安装brew和ab的最新版本。在最终采用这种方式之前,我尝试仅添加斜杠。
user$ ab http://dl.cubrid.org
ab: invalid URL
Usage: ab [options] [http[s]://]hostname[:port]/path
在以上消息中,请注意输入URL的所需格式。可选组件标有方括号,但请注意,/ path部分似乎不是可选的。因此,我假设如果要测试根域,则至少应添加尾部斜杠,这确实可以解决问题!我希望这对您也有帮助。
user$ ab dl.cubrid.org/
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 dl.cubrid.org (be patient).....done
Server Software:
Server Hostname: dl.cubrid.org
Server Port: 80
Document Path: /
Document Length: 13437 bytes
Concurrency Level: 1
Time taken for tests: 0.863 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Total transferred: 13606 bytes
HTML transferred: 13437 bytes
Requests per second: 1.16 [#/sec] (mean)
Time per request: 862.778 [ms] (mean)
Time per request: 862.778 [ms] (mean, across all concurrent requests)
Transfer rate: 15.40 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 207 207 0.0 207 207
Processing: 655 655 0.0 655 655
Waiting: 234 234 0.0 234 234
Total: 862 862 0.0 862 862
要测试的几件事:
如果上述两种方法均不能打开终端,
$ sudo opensnoop
然后运行apache bench,并在问题中发布opensnoop终端的输出。如果这些都不起作用,您可以尝试安装macports,然后从那里安装apache,然后查看它是否可以解决(有点la脚)。
My Air使用的是狮子,但apache版本不同(最近有更新,您已经安装了吗?)。我能够验证AB是否对我有用:
$ 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/
$ uname -a
Darwin air.local 11.1.0 Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64 x86_64
$ ab google.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 google.com (be patient).....done
Server Software: gws
Server Hostname: google.com
Server Port: 80
Document Path: /
Document Length: 219 bytes
Concurrency Level: 1
Time taken for tests: 4.130 seconds
Complete requests: 1
Failed requests: 0
Write errors: 0
Non-2xx responses: 1
Total transferred: 511 bytes
HTML transferred: 219 bytes
Requests per second: 0.24 [#/sec] (mean)
Time per request: 4130.343 [ms] (mean)
Time per request: 4130.343 [ms] (mean, across all concurrent requests)
Transfer rate: 0.12 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 4119 4119 0.0 4119 4119
Processing: 11 11 0.0 11 11
Waiting: 11 11 0.0 11 11
Total: 4130 4130 0.0 4130 4130
ab google.com/
工作对我来说,尝试ab -n 1000 -c 1000 google.com/