首页
其他
Action
Another action
Something else here
游客
登录系统
16
46小时前
小四
是不是只有我死了 是不是只有我死了 是不是只有我死了 是不是只有我死了 是不是只有我死了
25小时前
二愣子
呵呵
昨天
查看所有消息
16
46小时前
小四
是不是只有我死了 是不是只有我死了 是不是只有我死了 是不是只有我死了 是不是只有我死了
25小时前
二愣子
呵呵
昨天
查看所有消息
16
46小时前
小四
是不是只有我死了 是不是只有我死了 是不是只有我死了 是不是只有我死了 是不是只有我死了
25小时前
二愣子
呵呵
昨天
查看所有消息
发布创作
ubuntu中apache ab命令进行并发压力测试
超级管理员
|
462
|
2020-06-24
### 安装 ``` apt-get install apache2-utils ``` ### 基本用法 ``` # 对接口进行测试 # 对接口进行 1000 次请求,每次并发 100 次请求,会执行10次 $ ab -n 1000 -c 100 https://api.xxx.com/test.json?__v=1.0.0&__time=1592461058 # 结果 [1] 428 [2] 429 [3] 431 root@b2299d6a19d1:~# This is ApacheBench, Version 2.3 <$Revision: 1807734 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking api.xxx.com (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests -- 完成 100 次请求 Server Software: openresty/1.15.8.3 Server Hostname: api.xxx.com Server Port: 443 SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-SHA384,2048,256 TLS Server Name: api.xxx.com Document Path: /test.json Document Length: 78 bytes Concurrency Level: 100 -- 并发级别 Time taken for tests: 1.374 seconds -- 测试所用时间 Complete requests: 1000 Failed requests: 0 -- 失败的请求 Total transferred: 394000 bytes HTML transferred: 78000 bytes Requests per second: 727.73 [#/sec] (mean) Time per request: 137.414 [ms] (mean) Time per request: 1.374 [ms] (mean, across all concurrent requests) Transfer rate: 280.01 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 30 95 27.0 91 184 Processing: 12 37 16.7 33 121 Waiting: 9 33 16.3 28 121 Total: 45 131 34.8 126 266 Percentage of the requests served within a certain time (ms) -- 一定时间内送达请求的百分比(ms) 50% 126 66% 136 75% 143 80% 150 90% 166 95% 215 98% 247 99% 250 100% 266 (longest request) [1] Done ab -n 1000 -c 100 https://api.xxx.com/test.json [2] Done __v=1.0.0 [3]- Done __time=1592461058 ``` ### 参数说明 ``` # 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 一次并发的请求数 ( 总请求次数(n) = 次数 * 一次并发请求数(c)) -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 秒 -b windowsize Size of TCP send/receive buffer, in bytes TCP发送/接收缓冲区的大小(字节) -B address Address to bind to when making outgoing connections 进行传出连接时要绑定到的地址 -p postfile File containing data to POST. Remember also to set -T 包含要POST的数据。还记得设置-T -u putfile File containing data to PUT. Remember also to set -T 包含要PUT的数据。还记得设置-T -T content-type Content-type header to use for POST/PUT data, eg. 'application/x-www-form-urlencoded', Default is 'text/plain' 用于投递/投递数据的内容类型标题,例如. 'application/x-www-form-urlencoded', 默认 'text/plain' -v verbosity How much troubleshooting info to print 要打印多少故障排除信息 -w Print out results in HTML tables 在HTML表格中打印结果 -i Use HEAD instead of GET 用头代替GET -x attributes String to insert as table attributes 作为表属性插入的字符串 -y attributes String to insert as tr attributes 要作为tr属性插入的字符串 -z attributes String to insert as td or th attributes 作为td或th属性插入的字符串 -C attribute Add cookie, eg. 'Apache=1234'. (repeatable) 添加cookie,例如“Apache=1234”。(可重复) -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' Inserted after all normal header lines. (repeatable) 添加任意标题行,例如“Accept Encoding:gzip” 在所有正常标题行之后插入。(可重复) -A attribute Add Basic WWW Authentication, the attributes are a colon separated username and password. 添加基本的WWW身份验证,属性是以冒号分隔的用户名和密码。 -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 使用HTTP KeepAlive功能 -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 执行超过150个请求时不显示进度 -l Accept variable document length (use this for dynamic pages) 接受可变文档长度(用于动态页面) -g filename Output collected data to gnuplot format file. 将收集的数据输出到gnuplot格式文件。 -e filename Output CSV file with percentages served 输出提供百分比的CSV文件 -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 禁用TLS服务器名称指示(SNI)扩展 -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers) 指定SSL/TLS密码套件(请参阅openssl密码) -f protocol Specify SSL/TLS protocol (SSL2, TLS1, TLS1.1, TLS1.2 or ALL) 指定SSL/TLS协议 (SSL2、TLS1、TLS1.1、TLS1.2或全部) ```
一克字符 | EchoStr
互联网 ICP 备案:粤ICP备2024297332号
站长邮箱: echostr@163.com