使ApacheBench支持multi-url
程序员文章站
2022-04-13 10:30:46
TOC 由于标准的ab只支持对单个uri进行压测,不满足实际需要,故做以下修改,使ab支持multi url。 1、下载Apache httpd相关源码包以及针对ab工具的patch包 ~~~ wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/ ......
toc
由于标准的ab只支持对单个uri进行压测,不满足实际需要,故做以下修改,使ab支持multi-url。
1、下载apache httpd相关源码包以及针对ab工具的patch包
wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-1.6.5.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/apache/apr/apr-util-1.6.1.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.37.tar.gz wget https://github.com/philipgloyne/apachebench-for-multi-url/archive/master.zip
注:httpd依赖于apr和apr-util
2、编译安装apr
tar -zxf apr-1.6.5.tar.gz cd apr-1.6.5 ./configure --prefix=/usr/local/apr make && make install
3、编译安装apr-util
tar -zxf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install
4、替换httpd源码里面的ab.c文件
unzip master.zip tar -zxf httpd-2.4.37.tar.gz \cp ./apachebench-for-multi-url-master/ab.c ./httpd-2.4.37/support/
5、编译安装httpd
cd httpd-2.4.37 ./configure \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --prefix=/usr/local/apache \ --sysconfdir=/etc/httpd24 \ --enable-so \ --enable-ssl \ --enable-cgi \ --enable-rewrite \ --with-zlib \ --with-pcre \ --with-mpm=prefork \ --enable-modules=most \ --enable-mpms-shared=all make && make install
6、验证结果
#/usr/local/apache/bin/ab -h usage: /usr/local/apache/bin/ab [options] [http[s]://]hostname[:port]/path options are: -n requests number of requests to perform -c concurrency number of multiple requests to make -t timelimit seconds to max. wait for responses -b windowsize size of tcp send/receive buffer, in bytes -p postfile file containing data to post. remember also to set -t -u putfile file containing data to put. remember also to set -t -t content-type content-type header for posting, eg. 'application/x-www-form-urlencoded' default is 'text/plain' -v verbosity how much troubleshooting info to print -w print out results in html tables -i use head instead of get -x attributes string to insert as table attributes -y attributes string to insert as tr attributes -z attributes string to insert as td or th attributes -c attribute add cookie, eg. 'apache=1234. (repeatable) -h attribute add arbitrary header line, eg. 'accept-encoding: gzip' inserted after all normal header lines. (repeatable) -a attribute add basic www authentication, the attributes are a colon separated username and password. -p attribute add basic proxy authentication, the attributes are a colon separated username and password. -x proxy:port proxyserver and port number to use -v print version number and exit -k use http keepalive feature -d do not show percentiles served table. -s do not show confidence estimators and warnings. -g filename output collected data to gnuplot format file. -e filename output csv file with percentages served -r don't exit on socket receive errors. -h display usage information (this message) -l use url list file name, eg. url.txt -z ciphersuite specify ssl/tls cipher suite (see openssl ciphers) -f protocol specify ssl/tls protocol (ssl2, ssl3, tls1, or all)
可以看到ab已经支持-l参数(上面帮助信息的倒数第3行),大功告成。
上一篇: 这招这么神奇呀