Apache AB 壓力測試
安裝
// 安裝工具 yum install httpd-tools
使用
// URL 是網站請求路徑 ab -c 1000 -n 2000 "http://shop-app-envelope.mall.fenfenriji.com/envelope/data?enkey=d0hyf1or&uid=4040400&expires=1437460116&token=0f2aef4192f5374f85f844134ad14df5"
c併發量
n請求數
結果示例:
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking shop-app-envelope.mall.fenfenriji.com (be patient)
Completed 200 requests
Completed 400 requests
Completed 600 requests
Completed 800 requests
Completed 1000 requests
Completed 1200 requests
Completed 1400 requests
Completed 1600 requests
Completed 1800 requests
Completed 2000 requests
Finished 2000 requests
Server Software: nginx
Server Hostname: shop-app-envelope.mall.fenfenriji.com
Server Port: 80
Document Path: /envelope/data?enkey=d0hyf1or&uid=4040400&expires=1437460116&token=0f2aef4192f5374f85f844134ad14df5 #URL中的根絕對路徑
Document Length: 138 bytes #HTTP響應數據的正文長度
Concurrency Level: 1000 #併發用戶數
Time taken for tests: 9.087 seconds #所有這些請求被處理完成所花費的總時間
Complete requests: 2000 #總請求數量,這是我們設置的參數之一
Failed requests: 0 #失敗的請求數量
Write errors: 0
Total transferred: 776000 bytes #所有請求的響應數據長度總和
HTML transferred: 276000 bytes #所有請求的響應數據中正文數據的總和
Requests per second: 220.10 [#/sec] (mean) #吞吐率,計算公式:Complete requests / Time taken for tests
Time per request: 4543.349 [ms] (mean) #用戶平均請求等待時間,計算公式:Time token for tests/(Complete requests/Concurrency Level)
Time per request: 4.543 [ms] (mean, across all concurrent requests) #服務器平均請求等待時間,計算公式:Time taken for tests/Complete requests,正好是吞吐率的倒數。也可以這麼統計:Time per request/Concurrency Level
Transfer rate: 83.40 [Kbytes/sec] received #表示這些請求在單位時間內從服務器獲取的數據長度,計算公式:Total trnasferred/ Time taken for tests,這個統計很好的說明服務器的處理能力達到極限時,其出口寬帶的需求量。
Connection Times (ms)
min mean[+/-sd] median max
Connect: 2 44 54.9 16 186
Processing: 2069 3977 1830.1 4365 6841
Waiting: 2069 3977 1830.1 4365 6841
Total: 2071 4020 1879.2 4383 6982
Percentage of the requests served within a certain time (ms)
50% 4383
66% 5397
75% 5878
80% 6163
90% 6578
95% 6785
98% 6903
99% 6949
100% 6982 (longest request)
#整個場景中所有請求的響應情況。在場景中每個請求都有一個響應時間,其中50%的用戶響應時間小於4383毫秒,60% 的用戶響應時間小於5397毫秒,最大的響應時間小於6982毫秒