1张弛、接口壓力測試工具ab
ab是Apache超文本傳輸協(xié)議(HTTP)的性能測試工具仪缸。其設計意圖是描繪當前所安裝的Apache的執(zhí)行性能斯稳,主要是顯示你安裝的Apache每秒可以處理多少個請求礁击。
#下載測試工具
[root@nginx-server ~]# yum install httpd-tools
#壓力接口測試
[root@nginx-server ~]# ab -n 2000 -c 2 http://192.168.25.147/
-n 總的請求數(shù)
-c 并發(fā)數(shù)
2陕截、接口測試返回信息詳解
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 192.168.25.147 (be patient)
Completed 100 requests #已完成100個請求
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: nginx/1.16.1 #服務器軟件名稱及版本信息
Server Hostname: 192.168.25.147
#服務器主機IP
Server Port: 80 #服務器監(jiān)聽的端口
Document Path: / #供測試的URL路徑
Document Length: 612 bytes #供測試的URL返回的文檔大小
Concurrency Level: 500 #并發(fā)數(shù)
Time taken for tests: 0.285 seconds #壓力測試消耗的總時間
Complete requests: 1000 #請求的總次數(shù)
Failed requests: 0 #失敗的請求數(shù)
Write errors: 0 #網絡連接寫入錯誤次數(shù)
Total transferred: 845000 bytes #傳輸?shù)目倲?shù)據(jù)量
HTML transferred: 612000 bytes #HTML文檔的總數(shù)據(jù)量
Requests per second: 3508.09 [#/sec] (mean) #平均每秒的請求數(shù)(非常重要的參數(shù)驳棱,是服務器的吞吐量)
Time per request: 142.528[ms] (mean) #所有并發(fā)用戶(這里是500)都請求一次的平均時間
Time per request: 0.258[ms] (mean, across all concurrent requests)
#單個用戶請求一次的平均時間
Transfer rate: 2894.86 [Kbytes/sec] received #每秒獲取的數(shù)據(jù)長度 (傳輸速率,單位:KB/s)
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 13 12.2 6 39
Processing: 9 29 14.5 31 200
Waiting: 1 25 14.8 27 200
Total: 12 41 20.7 39 207
Percentage of the requests served within a certain time (ms)
50% 39 #50%的請求在39ms內返回
66% 55 #66%的請求在55ms內返回
75% 63 ......
80% 64
90% 66
95% 68
98% 69
99% 70
100% 207 (longest request)
3农曲、測試示例
被測試機:47.97.90.120 https://520.jingfei.xyz/
測試機:192.168.25.147
在測試機上下載測試工具
進行如下操作
[root@server2 ~]# ab -n 50 -c 2 https://520.jingfei.xyz/
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 520.jingfei.xyz (be patient).....done
Server Software: nginx/1.16.1
Server Hostname: 520.jingfei.xyz
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256
Document Path: /
Document Length: 13 bytes
Concurrency Level: 2
Time taken for tests: 8.691 seconds
Complete requests: 50
Failed requests: 0
Write errors: 0
Total transferred: 12150 bytes
HTML transferred: 650 bytes
Requests per second: 5.75 [#/sec] (mean)
Time per request: 347.641 [ms] (mean)
Time per request: 173.820 [ms] (mean, across all concurrent requests)
Transfer rate: 1.37 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 229 251 15.0 247 294
Processing: 72 83 5.6 82 96
Waiting: 72 81 5.6 80 95
Total: 309 334 16.1 329 374
Percentage of the requests served within a certain time (ms)
50% 329
66% 335
75% 341
80% 349
90% 360
95% 369
98% 374
99% 374
100% 374 (longest request)