使ApacheBench支持multi-url的方法

 更新时间:2021年01月04日 10:10:04   作者:wangqingyong  
这篇文章主要介绍了使ApacheBench支持multi-url的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

由于标准的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行),大功告成。

到此这篇关于使ApacheBench支持multi-url的方法的文章就介绍到这了,更多相关ApacheBench支持multi-url内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • 浅谈简单使用CentOS7防火墙及开放端口

    浅谈简单使用CentOS7防火墙及开放端口

    这篇文章主要介绍了浅谈简单使用CentOS7防火墙及开放端口,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-09-09
  • CentOS7.5从零安装Python3.6.6的教程详解

    CentOS7.5从零安装Python3.6.6的教程详解

    这篇文章主要介绍了CentOS7.5从零安装Python3.6.6的教程,本文通过实例图文相结合的形式给大家介绍的非常详细,具有一定的参考借鉴价值 ,需要的朋友可以参考下
    2018-10-10
  • Linux关机时执行指定脚本功能实现

    Linux关机时执行指定脚本功能实现

    本篇文章给大家分享了Linux关机时执行指定脚本功能的实现详解,对此有需要的朋友跟着小编一起学习下。
    2018-03-03
  • 用DNSPod和Squid打造自己的CDN (四)

    用DNSPod和Squid打造自己的CDN (四)

    感觉与上一篇一样,为了利于用户阅读,就不出重复了
    2013-04-04
  • CentOS服务器iptables配置简单教程

    CentOS服务器iptables配置简单教程

    这篇文章主要为大家详细介绍了CentOS服务器iptables配置简单教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2016-10-10
  • Linux 命令行通配符及转义符的实现

    Linux 命令行通配符及转义符的实现

    这篇文章主要介绍了Linux 命令行通配符及转义符的实现,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2018-11-11
  • Linux下PHP网站服务器安全配置加固防护方法【推荐】

    Linux下PHP网站服务器安全配置加固防护方法【推荐】

    本文详细总结了PHP网站在Linux服务器上面的安全配置,包含PHP安全、mysql数据库安全、web服务器安全、木马查杀和防范等,很好很强大很安全。感兴趣的朋友跟随脚本之家小编一起看看吧
    2018-08-08
  • CentOS中的正则表达式

    CentOS中的正则表达式

    这篇文章主要介绍了CentOS中的正则表达式 ,本文给大家介绍的非常详细,需要的朋友可以参考下
    2018-04-04
  • Linux服务器自定义登陆提示信息方式

    Linux服务器自定义登陆提示信息方式

    Linux系统中,可以通过配置/etc/issue、/etc/issue.net和/etc/motd文件来设置登录提示信息,便于用户了解系统配置和文件路径
    2024-11-11
  • 在Linux中精确测量域名解析时间的方法

    在Linux中精确测量域名解析时间的方法

    域名解析是互联网通信的基础环节之一,它负责将人类可读的域名(如 example.com)转换为机器可读的 IP 地址(如 93.184.216.34),本文将详细介绍如何在 Linux 系统中精确测量域名解析时间,涵盖多种工具和方法,帮助你从入门到精通,需要的朋友可以参考下
    2025-02-02

最新评论