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

一、工具使用:简单命令行: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.htmlThis is ApacheBench, Version 2.3 <$Revision: 1807734 gt;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 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsCompleted 500 requestsFinished 500 requestsServer Software: Microsoft-IIS/8.5Server Hostname: localhostServer Port: 80Document 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 bytesRequests 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 maxConnect: 0 0 1.1 0 21Processing: 114 424 589.3 301 3406Waiting: 114 423 589.1 300 3406Total: 114 424 589.2 302 3406Percentage 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了,不影响测试效果。ab压力测试截图

本文出自快速备案,转载时请注明出处及相应链接。

本文永久链接: https://kuaisubeian.cc/38569.html

kuaisubeian