【Code Tools】AB性能测试工具(二)

一、测试Get请求

1.每次并发请求10个,总共1000个请求

ab -n 1000 -c 10 https://www.baidu.com/

2.指定Header参数

通过-H来指定

ab -n 1000 -c 10 -H ‘Accept-Encoding: gzip‘ -H ‘storeId: 12‘ https://www.baidu.com/?a=1&b=2

二、测试Post请求

ab -n 1000 -c 10  -p "post.txt" -T "application/json" -H "Content-Type: application/json"  https://www.baidu.com/

-n:总请求次数(最小默认为 1);

-c:并发次数(最小默认为 1 且不能大于总请求次数,例如:10 个请求,10 个并发,实际就是 1 人请求 1 次);

-p:post 参数文档路径(-p 和 -T 参数要配合使用);

-T:用于POST/PUT数据的内容类型头(即设置post.txt中的参数类型)

其他参数如下:
通过ab -help查看

?  ~  ab -help
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make at a time
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -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 to use for POST/PUT data, 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.
    -q              Do not show progress when doing more than 150 requests
    -l              Accept variable document length (use this for dynamic pages)
    -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.
    -m method       Method name
    -h              Display usage information (this message)
    -I              Disable TLS Server Name Indication (SNI) extension
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (TLS1, TLS1.1, TLS1.2 or ALL)

原文地址:https://www.cnblogs.com/756623607-zhang/p/11144794.html

时间: 2024-07-29 15:09:30

【Code Tools】AB性能测试工具(二)的相关文章

ab性能测试工具

ab性能测试工具使用与测试结果详解 ab性能测试工具是Apache自带的一个性能测试工具,也是非常好用的. 命令: 两种参数结合: -n –c 并发测试: 在某种并发级别下(-c 100) 完成多少请求(-n 2000) 需要多久 2,-t –c 阶段高峰测试 在并发量为多大的情况下(-c), 在某个时间段内(-t),可以完成多少次请求 

转 Mac 使用ab性能测试工具

Mac 使用ab命令进行压测 1.在Mac中配置Apache ①启动Apache,打开终端 sudo apachectl -v 如下显示Apache的版本 sudo apachectl start 这样Apache就启动了.打开Safari浏览器地址栏输入 "http://localhost",可以看到内容为"It works!"的页面 ②设置虚拟端终机 打开Apache的配置文件 sudo vi /etc/apache2/httpd.conf 在httpd.con

Apache轻量级性能测试工具--ab

Apache轻量级性能测试工具--ab ab已经不是什么新鲜玩意,平时工作中会需要一些性能测试,很多工作完全可以由AB来替代,而不需要动用LR这样重量级的工具. 此文仅做个笔记,以便以后查阅. 1.安装:要使用AB,需要先安装Apache,它是Apache自带的测试工具(apache benchmark),在apache的安装目录下. 2.使用: 使用格式: ./ab [options] [http://]hostname[:port]/path 参数说明:     -n requests   

apache性能测试工具ab使用详解

网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环.只有让服务器处在高压情况下,才能真正体现出软件.硬件等各种设置不当所暴露出的问题. 性能测试工具目前最常见的有以下几种:ab.http_load.webbench.siege.今天我们专门来介绍ab. ab是apache自带的压力测试工具.ab非常实用,它不仅可以对apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试.比如nginx.tomcat.IIS等. 一.ab的原理 ab是apachebench命令的缩

烂泥:apache性能测试工具ab的应用

本文由秀依林枫提供友情赞助,首发于烂泥行天下. 网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环.只有让服务器处在高压情况下,才能真正体现出软件.硬件等各种设置不当所暴露出的问题. 性能测试工具目前最常见的有以下几种:ab.http_load.webbench.siege.今天我们专门来介绍ab. ab是apache自带的压力测试工具.ab非常实用,它不仅可以对apache服务器进行网站访问压力测试,也可以对或其它类型的服务器进行压力测试.比如nginx.tomcat.IIS等. 下面

Apache自带性能测试工具ab的使用

Apache服务器套件自带ab,只要安装Apache即可,无需另行安装ab.ab位于%ApacheHome%/bin目录下(“%ApacheHome%”为Aapche安装路径),你也可以把ab.exe文件copy出来,独立使用.  假设我们要测试一个PHP论坛系统,其中一个性能测试用例是:“同时处理50个并发请求并运行 1000 次index.php 首页”,我们可以在cmd shell中输入 ab -n 1000 -c 50 http://172.16.11.180:88/bbs/index.

几个性能测试工具

我个人认为一个优秀的软件工程师必须掌握一定的测试技能.可能有的开发工程师认为测试是测试工程师的事情,不是开发工程师的事情.这种开发工程师是缺一条腿的,离开了测试工程师,你如何证明你的程序没有问题. 下面是我这两天搜集的性能测试工具,如果大家知道别的工具,可以在回复中分享出来. Web Bench Web Bench is very simple tool for benchmarking WWW or proxy servers. Uses fork() for simulating multi

【腾讯开源】Android性能测试工具APT使用指南

[腾讯开源]Android性能测试工具APT使用指南 2014-04-23 09:58 CSDN CODE 作者 CSDN CODE 17 7833 腾讯 apt 安卓 性能测试 开源 我们近日对腾讯的安卓平台高效的性能测试工具APT团队进行了专访.APT,适用于开发自测和定位性能瓶颈,帮助完成性能基准测试.竞品测试.我们为大家准备了从安装部署到开启APT各功能的介绍资料,方便大家参考. 我们近日对腾讯的安卓平台高效的性能测试工具APT团队进行了专访.APT,Android Performanc

Apache轻量级性能测试工具

平时工作中会需要一些性能测试,简单的性能测试完全可以由AB来替代,而不需要动用LR这样重量级的工具. 此文简单介绍一下ab的工具使用与结果分析.当作个笔记,以便以后查阅. 1.安装:要使用AB,需要先安装Apache,它是Apache自带的测试工具(apache benchmark),在apache的安装目录下. 2.使用: 使用格式: ./ab [options] [http://]hostname[:port]/path 参数说明:     -n requests     Number of