ab壓力測試工具的簡單使用


ab是一種用於測試Apache超文本傳輸協議(HTTP)服務器的工具。apache自帶ab工具,可以測試
apache、IIs、tomcat、nginx等服務器
但是ab沒有Jmeter、Loadrunner那樣有各種場景設計、各種圖形報告和監控,只需一個命令即可,有輸出描述
可以簡單的進行一些壓力測試
 
一、Mac下自帶apache

查看版本 apachectl -v

以請求百度為例: http://httpd.apache.org/docs/2.4/programs/ab.html 詳細說明見官網
ab命令同時滿足http及https的請求
常用請求參數:-n請求次數,-c並發數
Wx-MacBookPro:apache2 wuxi$ ab -n 100 -c 10  https://www.baidu.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation,  http://www.apache.org/
//apache版本信息
Benchmarking www.baidu.com (be patient).....done
 
 
Server Software: BWS/1.1
//請求返回header類型,可能是nginx、apache、IIs等
Server Hostname:  www.baidu.com
//請求ip或者域名
Server Port: 443
//請求端口,當前請求為https所以端口為443,請求https端口80
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES128-GCM-SHA256,2048,128
//https端口協議
TLS Server Name: www.baidu.com
 
Document Path: /
//路徑
Document Length: 227 bytes
//第一個成功返回的文檔的字節大小
Concurrency Level: 10
//並發數!!!
Time taken for tests: 1.034 seconds
//從建立連接到最后接受完成總時間
Complete requests: 100
//總請求數成功的
Failed requests: 0
//失敗的
Total transferred: 87200 bytes
//從服務器接收的字節總數
HTML transferred: 22700 bytes
//HTML接收字節數
Requests per second: 96.75 [#/sec] (mean)
————每秒請求數(總請求數/總時間)
Time per request: 103.359 [ms] (mean)
————用戶平均請求等待時間=concurrency * timetaken * 1000 / done
參考Jmeter、LR中的平均響應時間
Time per request: 10.336 [ms] (mean, across all concurrent requests)
————服務器處理每個請求平均響應時間=timetaken * 1000 / done
Transfer rate: 82.39 [Kbytes/sec] received
 
Connection Times (ms)
min mean[+/-sd] median max
Connect: 41 75 16.1 74 121
Processing: 10 23 12.7 19 63
Waiting: 10 21 10.8 18 54
Total: 62 99 18.5 97 168
//網絡連接情況
Percentage of the requests served within a certain time (ms)
50% 97
66% 104
75% 107
80% 110
90% 126
95% 138
98% 148
99% 168
100% 168 (longest request)
//整體響應時間的分布比


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM