ab压测说明

本文介绍使用Apache Bench进行网站性能测试的方法,包括不同并发与请求数量下的测试结果,并详细解析了测试报告的各项指标。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

AB压测

ab结果分析字段说明参考

千度出来的运行结果的参数解释:

This is ApacheBench, Version 2.3 <$Revision: 655654 $> 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ 
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 192.168.0.10 (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 
Finished 800 requests


Server Software:        Microsoft-HTTPAPI/2.0 
Server Hostname:        ip 
Server Port:            port

Document Path:          / 
Document Length:        315 bytes       HTTP响应数据的正文长度

Concurrency Level:      800 
Time taken for tests:   0.914 seconds    所有这些请求处理完成所花费的时间 
Complete requests:      800             完成请求数 
Failed requests:        0                失败请求数 
Write errors:           0                
Non-2xx responses:      800 
Total transferred:      393600 bytes     网络总传输量 
HTML transferred:       252000 bytes     HTML内容传输量 
Requests per second:    875.22 [#/sec] (mean) 吞吐量-每秒请求数 
Time per request:       914.052 [ms] (mean)  服务器收到请求,响应页面要花费的时间 
Time per request:       1.143 [ms] (mean, across all concurrent requests) 并发的每个请求平均消耗时间 
Transfer rate:          420.52 [Kbytes/sec] received 平均每秒网络上的流量,可以帮助排除是否存在网络流量过大导致响应时间延长的问题


网络上消耗的时间的分解: 
Connection Times (ms) 
              min  mean[+/-sd] median   max 
Connect:        0    1   0.5      1       3 
Processing:   245  534 125.2    570     682 
Waiting:       11  386 189.1    409     669 
Total:        246  535 125.0    571     684

整个场景中所有请求的响应情况。在场景中每个请求都有一个响应时间 
其中 50% 的用户响应时间小于 571 毫秒 
80 % 的用户响应时间小于 652 毫秒 
最大的响应时间小于 684 毫秒 
Percentage of the requests served within a certain time (ms) 
  50%    571 
  66%    627 
  75%    646 
  80%    652 
  90%    666 
  95%    677 
  98%    681 
  99%    682 
100%    684 (longest request)

ab压测结果

直接执行ab.exe , 请求地址http://ip:port/default/skins/default/index.jsp

一:1000个请求,100个并发

This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking ip (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


Server Software:        Apache-Coyote/1.1
Server Hostname:        ip
Server Port:            port

Document Path:          /default/skins/default/index.jsp
Document Length:        2805 bytes

Concurrency Level:      100
Time taken for tests:   13.284 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      3051000 bytes
HTML transferred:       2805000 bytes
Requests per second:    75.28 [#/sec] (mean)
Time per request:       1328.447 [ms] (mean)
Time per request:       13.284 [ms] (mean, across all concurrent requests)
Transfer rate:          224.28 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   13  14.8      8     165
Processing:    17 1238 242.7   1281    1653
Waiting:        7  680 382.8    678    1512
Total:         23 1251 242.3   1295    1675

Percentage of the requests served within a certain time (ms)
  50%   1295
  66%   1359
  75%   1383
  80%   1409
  90%   1464
  95%   1504
  98%   1526
  99%   1571
 100%   1675 (longest request)

二:10000个请求,100个并发

This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking ip (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:        Apache-Coyote/1.1
Server Hostname:        ip
Server Port:            port

Document Path:          /default/skins/default/index.jsp
Document Length:        2805 bytes

Concurrency Level:      100
Time taken for tests:   118.002 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      30510000 bytes
HTML transferred:       28050000 bytes
Requests per second:    84.74 [#/sec] (mean)
Time per request:       1180.015 [ms] (mean)
Time per request:       11.800 [ms] (mean, across all concurrent requests)
Transfer rate:          252.50 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   11  17.3      7     299
Processing:    18 1164 338.0   1082    2994
Waiting:        6  664 404.5    632    2556
Total:         26 1175 340.4   1093    2999

Percentage of the requests served within a certain time (ms)
  50%   1093
  66%   1243
  75%   1324
  80%   1398
  90%   1601
  95%   1844
  98%   2173
  99%   2448
 100%   2999 (longest request)

三:10000个请求,3000个并发,用户登录系统测试

F:\httpd-2.4.46-o111g-x64-vc15\Apache24\bin>ab -n 10000 -c 3000 -C JSESSIONID=83013703AAEFC934D11E148EC4B85216 http://10.214.40.80:8083/default/skins/default/index.jsp
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking ip (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:        Apache-Coyote/1.1
Server Hostname:        ip
Server Port:            port

Document Path:          /default/skins/default/index.jsp
Document Length:        9018 bytes

Concurrency Level:      3000
Time taken for tests:   770.556 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      91590000 bytes
HTML transferred:       90180000 bytes
Requests per second:    12.98 [#/sec] (mean)
Time per request:       231166.887 [ms] (mean)
Time per request:       77.056 [ms] (mean, across all concurrent requests)
Transfer rate:          116.08 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        4   76 126.2     51    3196
Processing:   356 193401 69461.0 204115  291404
Waiting:       60 114998 73468.6 109935  290634
Total:        366 193477 69464.6 204179  291523

Percentage of the requests served within a certain time (ms)
  50%  204179
  66%  212253
  75%  233889
  80%  259279
  90%  283498
  95%  288447
  98%  289880
  99%  290671
 100%  291523 (longest request)
### HTTP工具 `ab` 的使用方法及参数说明 #### 工具概述 `ab` 是 Apache 自带的一个非常好用的测试工具,能够创建多个并发访问线程来模拟多个访问者同时对某一 URL 地址进行访问[^4]。 #### 安装方式 可以通过安装 `httpd-tools` 软件包来获取 `ab` 工具。具体操作如下: ```bash yum -y install httpd-tools ``` 确认安装成功可通过执行以下命令验证版本号: ```bash ab -V ``` 这将显示已安装的 `ab` 版本信息[^2]。 #### 参数详解 以下是常用的几个重要选项及其作用: - `-n requests`: 总共发送的请求数量。 - `-c concurrency`: 并发数,即同一时间有多少个请求被处理。 - `-t timelimit`: 测试的最大持续时间,在此期间尽可能多地发出请求直到达到指定的时间长度。 - `-p POSTfile`: 发送POST数据文件的内容作为POST请求的数据体。 - `-T content-type`: 设置Content-Type头字段,默认为 "text/plain"。 - `-v verbosity`: 显示详细的输出级别,0表示静默模式,最高可达4级详细程度。 - `-w`: 输出HTML表格形式的结果报告。 - `-k`: 启用HTTP KeepAlive特性,允许单次TCP连接上完成多次HTTP事务交互。 - `-H custom-header`: 添加自定义头部信息到每一个HTTP请求中去。 例如,要向目标网站发起1000个请求并保持每秒最多5个并发连接,则可以这样调用: ```bash ab -n 1000 -c 5 http://example.com/ ``` 如果需要上传表单数据,还可以通过 `-p` 和 `-T` 来指明提交的数据格式以及具体的文件路径: ```bash ab -n 100 -c 10 -p post_data.txt -T application/x-www-form-urlencoded http://example.com/submit_form.php ``` 以上就是关于如何利用 `ab` 进行简单的HTTP服务端性能评估的一些指导[^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值