Apache壓力測試工具ab使用詳解

2021-07-22 22:20:51 字數 4821 閱讀 4224

apache附帶的壓力測試工具ab,非常容易使用,並且完全可以摸你各種條件對web伺服器發起測試請求。ab可以直接在web伺服器本地發起測試請求,這對於需要了解伺服器的處理效能至關重要,因為它不包括資料的網路傳輸時間以及使用者pc本地的計算時間。

下面我們開始壓力測試(環境說明:win7,需要在命令列cmd中切換至ab.exe所在目錄),執行以下命令:

執行結果如下:

1this is apachebench, version 2.3 <$revision: 655654 $>

2

3licensed to the apache software foundation,

4

5benchmarking localhost (be patient)

6completed 100 requests

7completed 200 requests

8completed 300 requests

9completed 400 requests

10completed 500 requests

11completed 600 requests

12completed 700 requests

13completed 800 requests

14completed 900 requests

15completed 1000 requests

16finished 1000 requests

17

18server software:        apache/2.2.21

19server hostname:        localhost

20server port:            80

21

22document path:          /index.php/

23document length:        0 bytes

24

25concurrency level:      10

26time takenfortests:   1.047 seconds

27complete requests:      1000

28failed requests:        0

29write errors:           0

30total transferred:      187000 bytes

31html transferred:       0 bytes

32requests per second:    955.06 [#/sec] (mean)

33time per request:       10.471 [ms] (mean)

34time per request:       1.047 [ms] (mean, across all concurrent requests)

35transfer rate:          174.41 [kbytes/sec] received

36

37connection times (ms)

38min  mean[+/-sd] median   max

39connect:        0    0   0.5      0       4

40processing:     2   10   4.5      9      42

41waiting:        2   10   4.5      9      41

42total:          2   10   4.5      9      42

43

44percentage of the requests served within a certaintime(ms)

4550%      9

4666%     11

4775%     13

4880%     15

4990%     17

5095%     18

5198%     20

5299%     21

53100%     42 (longest request)

-n1000 :總請求數為1000

-c10 :併發使用者數為10

http://localhost/index.php/ :表示這些請求的目標url

server software:表示被測試的web伺服器軟體名稱

server hostname:表示請求的url中的主機名稱,這裡是localhost

server port:表示被測試的web伺服器軟體的監聽埠

document path:表示請求的url中的根絕對路徑

document length:表示http響應資料的正文長度

concurrency level:表示併發使用者數,這是我們設定的引數

time taken for tests:表示所有這些請求被處理完成所要花費的總時間

complete requests:表示總請求數,這也是我們設定的引數

failed requests:表示失敗的總請求數,這裡的失敗指請求在連線伺服器、傳送資料、接收資料等環節發生異常,以及無響應超時等情況

total transferred:表示所有請求的響應資料長度總和,包括http響應的頭資訊和正文資料的長度

html transferred:表示所有請求的響應資料中正文資料的總和

requests per second:表示伺服器吞吐率(這是我們應該重點關注的)

time per request:表示使用者平均請求的等待時間

time per request (mean, across all concurrent requests):表示伺服器平均請求處理時間

transfer rate:表示這些請求在單位時間內從伺服器獲取的資料長度

percentage of the requests served within a certain time (ms):這部分資料描述每個請求處理時間的分布情況

Apache 壓力測試工具 ab

每當搭建完web伺服器,部署好web專案或是優化調整後,我們可能想知道服務的效率和效能如何,以便了解伺服器的處理能力是否達到預期效果或是檢測伺服器效能。apache 2自帶了乙個效能測試工具,叫做ab apache benchmarking 它的主要功能是,測試當前的web伺服器每秒鐘能夠處理的請求...

apache自帶壓力測試工具ab詳解

ab 壓力測試命令 格式 ab options http hostname port path n 測試會話中所執行的請求個數,預設時,僅執行乙個請求 c 一次產生的請求個數。預設是一次乙個 t 測試所進行的最大秒數 v 設定顯示資訊的詳細程度 4或更大值會顯示頭資訊,3或更大值可以顯示響應 404...

ab壓力測試工具

即ab的主要邏輯包含在test方法中。test方法首先進行了一些全域性的初始化工作。其中,最重要的乙個資料結構是陣列struct connection con c 代表同時存在的c個客戶端連線。struct connection的結構如下 struct connection start connec...