1、安裝
yum -y install httpd-tools
2、檢測版本
ab -V
3、常用文章來源:http://www.zghlxwxcb.cn/news/detail-570553.html
ab -c 10 -n 100 127.0.0.1/index.php #同時處理100個請求并運行10次index.php #-c10表示并發(fā)用戶數(shù)為10 #-n100表示請求總數(shù)為100
4、解釋文章來源地址http://www.zghlxwxcb.cn/news/detail-570553.html
[root@zhy html]# ab -n100 -c10 127.0.0.1/index.php
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 127.0.0.1 (be patient).....done
Server Software: Apache #測試服務(wù)器的名字
Server Hostname: 127.0.0.1 #請求的URL主機(jī)名
Server Port: 80 #web服務(wù)器監(jiān)聽的端口
Document Path: /index.php #請求的URL中的根絕對路徑
Document Length: 211 bytes #HTTP響應(yīng)數(shù)據(jù)的正文長度
Concurrency Level: 10 # 并發(fā)用戶數(shù),即-c10
Time taken for tests: 0.010 seconds #所有這些請求被處理完成所花費的總時間 單位秒
Complete requests: 100 # 總請求數(shù)量,即-n100
Failed requests: 0 # 表示失敗的請求數(shù)量,這里的失敗是指請求在連接服務(wù)器、發(fā)送數(shù)據(jù)等環(huán)節(jié)發(fā)生異常,以及無響應(yīng)后超時的情況
Write errors: 0
Non-2xx responses: 100
Total transferred: 41000 bytes #所有請求的響應(yīng)數(shù)據(jù)長度總和。包括每個HTTP響應(yīng)數(shù)據(jù)的頭信息和正文數(shù)據(jù)的長度
HTML transferred: 21100 bytes # 所有請求的響應(yīng)數(shù)據(jù)中正文數(shù)據(jù)的總和,也就是減去了Total transferred中HTTP響應(yīng)數(shù)據(jù)中的頭信息的長度
Requests per second: 9994.00 [#/sec] (mean) #吞吐率,計算公式:Complete requests/Time taken for tests 總請求數(shù)/處理完成這些請求數(shù)所花費的時間
Time per request: 1.001 [ms] (mean) # 用戶平均請求等待時間,計算公式:Time token for tests/(Complete requests/Concurrency Level),處理完成所有請求數(shù)所花費的時間/(總請求數(shù)/并發(fā)用戶數(shù))
Time per request: 0.100 [ms] (mean, across all concurrent requests) #服務(wù)器平均請求等待時間,計算公式:Time taken for tests/Complete requests,正好是吞吐率的倒數(shù)。也可以這么統(tǒng)計:Time per request/Concurrency Level
Transfer rate: 4001.51 [Kbytes/sec] received #表示這些請求在單位時間內(nèi)從服務(wù)器獲取的數(shù)據(jù)長度,計算公式:Total trnasferred/ Time taken for tests,這個統(tǒng)計很好的說明服務(wù)器的處理能力達(dá)到極限時,其出口寬帶的需求量。
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 1 1 0.1 1 1
Waiting: 0 1 0.1 1 1
Total: 1 1 0.1 1 1
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 1
95% 1
98% 1
99% 1
100% 1 (longest request)
#Percentage of requests served within a certain time(ms)這部分?jǐn)?shù)據(jù)用于描述每個請求處理時間的分布情況,比如以上測試,100%的請求處理時間都不超過1ms,這個處理時間是指前面的Time per request,即對于單個用戶而言,平均每個請求的處理時間
到了這里,關(guān)于DevOps系列文章 之 linux ab壓力測試的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!