ab(Apache Benchmark)运行apr_socket_recv报错

在Mac OS X Lion下运行ab会报如下错误:

apr_socket_recv: Connection reset by peer (54)

比如:

$ ab -n 1000 -c 10 http://localhost:8888/
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 localhost (be patient)
Send request failed!
Send request failed!
Send request failed!
apr_socket_recv: Connection reset by peer (54)

新版的Apache已经解决了这个问题,可以获取源代码并编译如下:

wget http://mirrors.kahuki.com/apache//httpd/httpd-2.3.16-beta.tar.bz2
tar jxvf httpd-2.3.16-beta.tar.bz2 
cd httpd-2.3.16
./configure

我只需要一个ab,所以只编译support目录即可。

cd support
make
#...

重新运行ab

./ab -n 1000 -c 10 http://localhost:8888/

Bingo! :)

对于老一些的版本的Apache,需要打补丁

wget https://www.rtfm.ro/download/patches/ab.patch --no-check-certificate
patch -p0 < ./ab.patch

会有一行出错,不要理,继续往下走。

patching file support/ab.c
Hunk #1 FAILED at 670.
Hunk #2 FAILED at 1683.
Hunk #3 FAILED at 1767.
3 out of 3 hunks FAILED -- saving rejects to file support/ab.c.rej

然后按前面的步骤编译Apache的support目录。

你可能感兴趣的:(linux)