Apache的ab压力测试工具与性能监控

【图书介绍】《软件性能测试、分析与调优实践之路(第2版)》_软件性能测试分析与调优实践之路-CSDN博客
《软件性能测试、分析与调优实践之路(第2版)》(张永清)【摘要 书评 试读】- 京东图书 (jd.com)

Apache的ab压力测试工具

Apache中自带了性能压测工具ab,一些比较简单的压力测试请求可以直接使用这个性能压测工具ab来完成。ab使用起来非常简单方便,直接可以通过命令行执行ab命令,或者在命令后面加上对应的参数即可开启性能压测。

ab支持的常用参数如下:

  1. -n requests:表示总计发送多少请求。
  2. -c concurrency:代表客户端请求的并发连接的数量。
  3. -k:开启Http KeepAlive。
  4. -s timeout:设置响应的超时时间,默认为30秒。
  5. -b windowsize:设置TCP请求发送和接收的缓冲区大小,单位为字节。
  6. -f protocol:指定SSL/TLS协议(支持SSL3、TLS1、TLS1.1、TLS1.2或者all)。
  7. -g filename:输出收集到的压测数据到gnuplot 格式的文件中,gnuplot是一个命令行的交互式绘图工具。
  8. -e filename:输出收集到的压测数据到csv 格式的文件中。
  9. -r:表示在socket接收到错误时,ab压测不退出。
  10. -X proxy:port:设置压测请求地址的代理服务器地址。

示例:ab -n 10000 -c 60 -k http://127.0.0.1:80/ 表示总共发送10 000次压测请求,并发连接数为60,并且在压测时客户端开启KeepAlive。

[root@localhost conf]# ab -n 10000 -c 60 -k  http://127.0.0.1:80/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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:        Apache/2.4.6
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /
Document Length:        4897 bytes

Concurrency Level:      60
Time taken for tests:   4.014 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Non-2xx responses:      10000
Keep-Alive requests:    9916
Total transferred:      52046232 bytes
HTML transferred:       48970000 bytes
Requests per second:    2491.21 [#/sec] (mean)
Time per request:       24.085 [ms] (mean)
Time per request:       0.401 [ms] (mean, across all concurrent requests)
Transfer rate:          12661.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       8
Processing:     0   11  65.9      8    2474
Waiting:        0   11  65.9      7    2474
Total:          0   11  66.0      8    2474

Percentage of the requests served within a certain time (ms)
  50%      8
  66%      8
  75%      8
  80%      9
  90%     11
  95%     12
  98%     15
  99%     34
 100%   2474 (longest request)

Apache的性能监控

Apache自身自带了状态监控页面,但是默认是关闭的,可以通过在httpd.conf中增加如下配置来打开监控页面。

<location /server-status>

    SetHandler server-status

    Order Deny,Allow

    Allow from all

</location>

增加上述配置后,然后就可以通过访问http://ip:port/server‐status来查看监控页面了,如图3-2-6和图3-2-7所示。

图3-2-6

图3-2-7

从上图中可以看到如下数据:

(1)Total accesses:对Apache的访问量。

(2)Total Traffic:Apache的访问流量,单位为KB。

(3)CPU Usage:CPU的使用情况。

(4)每秒收到的请求的统计信息:0.0513 requests/sec - 105 B/second - 2048 B/request,表示平均每秒收到0.0513个请求,平均每秒收到的请求流量为105字节,每个请求的平均大小为2048字节。

(5)请求的处理情况:1 requests currently being processed, 8 idle workers,表示目前1个请求正在被处理(状态为w,表示处理发送回复状态),目前有8个线程处于空闲状态。

(6)目前运行的Apache进程的资源使用情况以及客户端的连接情况,如图3-2-8所示。

图3-2-8

从图中可以看到,当前有4个进程正在工作中,并且PID为1925的进程当前正在处理一个HTTP的GET请求。

相关推荐
沈艺强4 小时前
伊犁云计算22-1 apache 安装rhel8
apache
鸠摩智首席音效师4 小时前
如何配置 Apache 反向代理服务器 ?
apache
CC城子9 小时前
Wireshark学习使用记录
学习·测试工具·wireshark
Hello.Reader9 小时前
深入解析 Apache Doris架构、应用场景与最佳实践
大数据·架构·数据分析·apache
某公司摸鱼前端16 小时前
js 如何代码识别Selenium+Webdriver
javascript·selenium·测试工具·js
职教育人20 小时前
金砖软件测试赛项之Jmeter如何录制脚本!
java·测试工具·jmeter·性能优化·集成测试
汽水配辣条1 天前
安装selenium、chrome、chromedriver.exe相对应的版本
chrome·selenium·测试工具
qq_433716951 天前
UI自动化测试的边界怎么定义?
自动化测试·软件测试·测试工具·jmeter·ui·接口测试·postman
pjx9872 天前
JVM 性能调优与监控
jvm·测试工具