centos8平台使用ab做压力测试
一,安装ab
[root@blog ~]# yum install httpd-tools
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,查看版本和帮助
1,查看版本
[root@blog ~]# ab -V
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
2,查看帮助:
[root@blog ~]# ab -h
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
(SSL2, TLS1, TLS1.1, TLS1.2 or ALL)
-E certfile Specify optional client certificate chain and private key
三,常用参数说明
-n: 总的请求个数
-c: 一次并发的请求数
-t: 持续的时间,默认没有限制
-k:它会增加请求头Connection: Keep-Alive,相当于开启了HTTP长连接,
这样做一方面可以降低测试服务器动态端口被耗尽的风险,
另一方面也有助于给目标服务器更大的压力,测试出更接近极限的结果
说明:ab使用的是HTTP/1.0,缺省开启的是短链接,用-k参数则可以打开长连接
四,ab运行的例子:
1,运行命令:一次100个并发请法庭,共10000个请求
[root@centos8 conf]# ab -c 100 -n 10000 http://127.0.0.1/a.html
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests Server Software: openresty/1.15.8.3
Server Hostname: 127.0.0.1
Server Port: 80
Document Path: /a.html
Document Length: 34 bytes Concurrency Level: 100
Time taken for tests: 0.968 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 2710000 bytes
HTML transferred: 340000 bytes
Requests per second: 10335.21 [#/sec] (mean)
Time per request: 9.676 [ms] (mean)
Time per request: 0.097 [ms] (mean, across all concurrent requests)
Transfer rate: 2735.20 [Kbytes/sec] received Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 2 2.1 2 15
Processing: 1 7 3.7 6 22
Waiting: 0 6 3.2 5 18
Total: 3 10 3.7 9 23 Percentage of the requests served within a certain time (ms)
50% 9
66% 11
75% 12
80% 13
90% 15
95% 17
98% 19
99% 20
100% 23 (longest request)
五,ab运行结果的输出字段说明:
1,值得注意的字段
请求汇总中的各字段:
Document Length: # 请求的页面大小
Concurrency Level: # 每次的并发请求数
Time taken for tests: # 测试总共耗时
Complete requests: # 完成的请求总数
Failed requests: # 失败的请求数量
Write errors: # 错误的请求数量
Total transferred: # 总共传输数据量
Requests per second 吞吐率(reqs/s):服务器每秒能够处理的请求数量
Time per request 平均请求处理时间
它的两个值是:第一行为每次并发请求的耗时,
第二行为每个请求的耗时
第一行值为第二行的值乘上并发请求数量。
可以尝试将并发数改为20,
这样就会看到第一行是第二行的20倍
Transfer rate 表示吞吐量(BPS):
即:每秒从服务器获取的数据的长度
连接时间汇总部分,则是分别展示了建立连接、请求、等待以及汇总等的各类时间,包括最小、最大、平均以及中值处理时间。
Connect: 建立连接
Processing: 处理请求
Waiting: 等待
Total: 全部时间
min 最小
mean[+/-sd] 平均
median 中值
max 最大
请求延迟汇总部分:给出了不同时间段内处理请求的百分比
例子:
75% 24
75% 的请求,都可以在 24ms 内完成。
2,最常用的字段:
Requests per second 吞吐率
3,请求失败Failed requests时注意查找原因:
例如:
Failed requests: 9991
(Connect: 0, Receive: 0, Length: 9991, Exceptions: 0)
Non-2xx responses: 9991
Connect:无法送出要求、目标主机连接失败、请求的过程中连接被中断
Receive:当客户端connect成功后,并且服务端成功accept,并且没有开始recv,
然后服务端close掉socket,就产生这个错误
平时多见于服务端主动close掉客户端连接,即客户端表现为Connection reset by peer
Length:即读到的报文长度不等于http头的content-length值
Exceptions:多见于网络发生错误
做ab压测时,注意先把waf防火墙关掉,我遇到的这个问题在waf关闭后恢复正常
六,查看centos的版本:
[root@blog ~]# cat /etc/redhat-release
CentOS Linux release 8.0.1905 (Core)
centos8平台使用ab做压力测试的更多相关文章
- centos8平台使用stress做压力测试
一,安装stress: 说明:el8的源里面还没有,先用el7的rpm包 [root@centos8 source]# wget https://download-ib01.fedoraproject ...
- Linux学习13-CentOS安装ab做压力测试
前言 网站性能压力测试是服务器网站性能调优过程中必不可缺少的一,测试环境准备好了后,如何对网站做压力测试? 压力测试的工具很多,如:ab.http_load.webbench.siege.jmeter ...
- ab做压力测试
ab是apache 自带的一个压力测试的小工具,可用于接口简单的压力测试. 以下是AB的简要介绍 格式:ab [options] [http://]hostname[:port]/path 参数说明: ...
- ubuntu下 使用AB做压力测试
1最近刚开始接触apache大数据下数据优化,讲一下apache 下ab压力测试工具. 程序“ab”尚未安装. 您可以使用以下命令安装: apt-get install apache2-utils 以 ...
- 使用Apache Benchmark做压力测试遇上的5个常见问题
这一篇文章主要记录我在使用Apache Benchmark(一下检测ab)做网站压力测试的过程中,遇到的一些问题以及解决办法,方便日后使用. 这一篇文章主要记录我在使用Apache Benchmark ...
- Webbench、ab命令:做压力测试的工具和性能的监控工具
DDOS攻击:???DDOS概述:分布式拒绝服务(DDoS:Distributed Denial of Service)攻击,指借助于客户/服务器技术,将多个计算机联合起来作为攻击平台,对一个或多个目 ...
- 在linux中给你的应用做压力测试
在linux中给你的应用做压力测试 作者: 立地 邮箱: jarvin_g@126.com QQ: 511363759 一.webbench 1.在Ubuntu中安装webbench —支持get,h ...
- (转)学习使用Jmeter做压力测试(三)--数据库测试
数据库测试 JMeter可以做为Web服务器与浏览器之间的代理网关,以捕获浏览器的请求和Web服务器的响应,这样就可很容易的生成性能测试脚本. 根据脚本,JMeter可通过线程组来模拟真实用户对Web ...
- 使用JMeter做压力测试
使用JMeter做压力测试 1.下载Jmeter 地址:http://jmeter.apache.org/download_jmeter.cgi 2.启动jmeter 运行bin/jmeter.bat ...
随机推荐
- 初识ABP vNext(9):ABP模块化开发-文件管理
Tips:本篇已加入系列文章阅读目录,可点击查看更多相关文章. 目录 前言 开始 创建模块 模块开发 应用服务 运行模块 单元测试 模块使用 最后 前言 在之前的章节中介绍过ABP扩展实体,当时在用户 ...
- Noip2017 Day2 T1 奶酪
题目描述 现有一块大奶酪,它的高度为 h,它的长度和宽度我们可以认为是无限大的,奶酪中间有许多半径相同的球形空洞.我们可以在这块奶酪中建立空间坐标系,在坐标系中,奶酪的下表面为z =0,奶酪的上表面为 ...
- Mybatis接口Mapper内的方法为啥不能重载吗?
动态代理的功能:通过拦截器方法回调,对目标target方法进行增强. 言外之意就是为了增强目标target方法.上面这句话没错,但也不要认为它就是真理,殊不知,动态代理还有投鞭断流的霸权,连目标tar ...
- 基于python的extract_msg模块提取outlook邮箱保存的msg文件中的附件
笔者保存了一些outlook邮箱中保存的一些msg格式的邮件文件,现需要将其中的附件提取出来, 当然直接在outlook中就可以另存附件,但outlook默认是不支持批量提取邮件中的附件的 思考过几种 ...
- C语言入门经典书目推荐--转
国内良莠不齐的C语言教程数不胜数,同名如"C程序设计""C语言程序设计""C语言程序设计教程"的都多如牛毛,这些不知名的就不予考虑了,要看就 ...
- 搭建Linux服务器
工欲善其事必先利其器, 虚拟机:百度云链接地址:https://pan.baidu.com/s/1_nWQh3WKF7xLs5-nmbZ8lA (Vmware 12 ) Linux 7:百度云链接 ...
- 本地保存cookie
原文https://blog.csdn.net/qq_29663071/article/details/73826642 https://www.cnblogs.com/webcome/p/54709 ...
- 修改默认配置文件.android.gradle.androidstudio到其他目录
.android 这个文件夹主要是用来存放模拟器的,是占用空间最大的一个,如果你没有使用它的模拟器,可以直接把这个文件夹删除.因为我建立了两个x86的模拟器,吃掉了我20G的空间.果断搬走. 复制当前 ...
- React学习小记--setState的同步与异步
react中,state不能直接修改,而是需要使用setState()来对state进行修改,那什么时候是同步而什么时候是异步呢? 基础代码: setCounter = (v) => { thi ...
- Python3基础——函数
ython 函数 函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段. 函数能提高应用的模块性,和代码的重复利用率.你已经知道Python提供了许多内建函数,比如print().但你也可 ...