apache自带网站压力测试工具ab的使用和分析

作者 : 开心源码 本文共1852个字,预计阅读时间需要5分钟 发布时间: 2022-05-12 共104人阅读

一、工具使用:

简单命令行:ab -n 500 -c 50 http://localhost/ 意思是50个客户并发访问http://localhost/,共500次请求。

二、工具获取:

ab压力测试工具是apache中带的,假如电脑中有安装apache则在命令行进入apache的bin目录进行运行就可;

假如没有apache则下载单独的apache就可,windows下没有官方编译的二进制文件,按照官方页面引导(http://httpd.apache.org/docs/current/platform/windows.html)去(https://www.apachehaus.com/cgi-bin/download.plx)下载Apache 2.4.28 x64(或者32位),而后解压缩,而后cmd到bin目录运行ab工具就可;

直接cmd运行httpd.exe就是一个独立的apache服务器。

三、工具测试结果分析:

粗体字的QPS和客户等待时间是两个重要需要关注的参数!

E:\apache24\bin>ab -n 500 -c 50 http://localhost/article-4330.html

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Finished 500 requests

Server Software: Microsoft-IIS/8.5

Server Hostname: localhost

Server Port: 80

Document Path: /article-4330.html #测试路径

Document Length: 19954 bytes #测试页面文件大小

Concurrency Level: 50 #并发数

Time taken for tests: 4.301 seconds #总共消耗的时间

Complete requests: 500 #总请求数

Failed requests: 0 #失败数量

Total transferred: 10170000 bytes #总共传送数据量

HTML transferred: 9977000 bytes

Requests per second: 116.25 [#/sec] (mean) #QPS每秒多少请求,这个是非常重要的参数数值,服务器的吞吐量

Time per request: 430.124 [ms] (mean)#客户平均请求等待时间

Time per request: 8.602 [ms] (mean, across all concurrent requests)#服务器平均解决时间,也就是服务器吞吐量的倒数

Transfer rate: 2309.02 [Kbytes/sec] received##每秒获取的数据长度

Connection Times (ms)

min mean[+/-sd] median max

Connect: 0 0 1.1 0 21

Processing: 114 424 589.3 301 3406

Waiting: 114 423 589.1 300 3406

Total: 114 424 589.2 302 3406

Percentage of the requests served within a certain time (ms)

50% 302

66% 344

75% 365

80% 385

90% 455

95% 1461

98% 3324

99% 3366

100% 3406 (longest request)

E:\apache24\bin>

有时候出现大量的 Failed requests,分別有 Connect, Length,Exception :

1:Connect 无法送出要求,目标主机连接失败,要求的过程中连接被中断

2:Length 回应的内容长度不一致(以Content-Lenght) 标头值为判断依据

3:Exception 发生无法预期的错误

假如错误出现在Length上,只需更改测试的地址回应的内容长度就ok了,或者简单的来个 return 0; 就OK了,不影响测试效果。

apache自带网站压力测试工具ab的使用和分析

ab压力测试截图

说明
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是摆设,本站源码仅提供给会员学习使用!
7. 如遇到加密压缩包,请使用360解压,如遇到无法解压的请联系管理员
开心源码网 » apache自带网站压力测试工具ab的使用和分析

发表回复