ab命令压测

在性能调优中,ab命令和iperf命令比较好用的,下面就介绍一下ab命令

ApacheBench

ab是apacheBench的缩写,是一个单线程命令,是Apache服务器自带的一个web压力测试工具,最初是用于测试Apache HTTP Server。使用时,ab命令会创建并发访问线程,模拟多个访问者同时对某一个URL地址进行访问。

使用的方法:

ab [option] [http://]host[:port]/path

例如:ab -n 100 -c 10 "http://en.wikipedia.org/wiki/Main_Page"

其中[option]是ab命令提供的可选参数,列举一些常用的参数:

-n  //requests Number of requests to perform 指定压力测试总共访问页面的次数,默认是1

-c //concurrency Number of multiple requests to make at a time 用于一次产生请求的并发数,默认是1

-r //Don't exit on socket receive errors.指定接收到错误信息时不退出程序。

-B //address Address to bind to when making outgoing connections 绑定出口IP地址

-t //timelimit Seconds to max. to spend on benchmarking This implies -n 50000 测试所进行的最大秒数。其内部隐含值是-n 50000。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。

-s //timeout  Seconds to max. wait for each response Default is 30 seconds  每个相应的最长的时间,默认是30秒

-g //filename Output collected data to gnuplot format file  输出结果信息到gnuplot格式的文件中。

-e //filename  Output CSV file with percentages served   输出结果信息到CSV格式的文件中。

-S // Do not show confidence estimators and warnings. 不显示预估和警告信息。

-d //Do not show percentiles served table. 不显示百分比。

-k //Use HTTP KeepAlive feature    使用HTTP的KeepAlive特性。

-b //windowsize   Size of TCP send/receive buffer, in bytes TCP的发送/接受窗口,以字节为单位

-p //postfile File containing data to POST 包含需要post的数据文件,例如:-p  a.txt,此外还需要结合-T,并且文件的内容需类似像"key1=value1&key2=vaule2"形式

-T //content-type Content-type header for POSTing 设置Context-Type请求头信息,如-T “application/x-www-form-urlencoded”默认值为text/plain

-X //proxy:port  Proxyserver and port number to use 指定使用的代理服务器和端口号,例如:"126.10.10.3:88"

-v //verbosity How much troubleshooting info to print 设置打印帮助信息的详细程度,4或更大值会显示头信息, 3或更大值可以显示响应代码(404, 200等), 2或更大值可以显示警告和其他信息。

-w //Print out results in HTML tables 以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。

-i  //Use HEAD instead of GET 使用HEAD请求代替GET请求

-C //cookie-name=value 添加cookie信息,其典型形式是name=value的一个参数对。此参数可以重复,用逗号分割。

-H //attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip' Inserted after all normal header lines. (repeatable) 添加任意的请求头,例如:"Accept-Encoding: gzip",此参数可重复

-P // proxy-auth-username:password  对一个中转代理提供BASIC认证信任。用户名和密码用英文冒号隔开,并以base64编码形式发送。无论服务器是否需要(即, 是否发送了401认证需求代码),此字符串都会被发送。

-A //Add Basic WWW Authentication, the attributes are a colon separated username and password.基本网络认证,用户名和密码之间用英文冒号隔开。

-x //attributes   String to insert as table attributes 插入字符串作为table标签的属性。

-y //attributes   String to insert as tr attributes 插入字符串作为tr标签的属性。

-z //attributes   String to insert as td or th attributes 插入字符串作为td标签的属性。

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喝醉的鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值