apache 的ab 工具

來源:互聯網
上載者:User

標籤:

ab是apache 進行http伺服器壓力測試的一個工具。用來衡量apache 伺服器的執行效率,能夠檢測出apache每秒能夠處理的請求數。

一個使用的例子如下(windows下)

ab -n 100 -c 10 http://www.baidu.com/

上面這個命令能夠檢測百度伺服器的承壓情況,其中-n 100表示總共發起100個串連請求,而-c 10表示同時維持10個並發。測試結果如下和欄位的含義解釋如下(飄黃是解釋):

This is ApacheBench, Version 2.3 <$Revision: 1554214 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking www.baidu.com (be patient).....done

Server Software: BWS/1.1 ## 伺服器的軟體名稱, 如果是apache,則會顯示是apache,這個欄位選自http的response頭部的header 欄位Server Hostname: www.baidu.com ## 請求的網域名稱Server Port: 80      ## 請求的連接埠Document Path: /        ## 本次請求的文檔路徑Document Length: 86001 bytes  ## 請求的response的文檔大小Concurrency Level: 10     ## 並發度,對應了命令中的 -c 10Time taken for tests: 6.901 seconds  ## 測試花費的時間Complete requests: 100        ## 完成的請求個數Failed requests: 95        ## 失敗的請求個數 (Connect: 0, Receive: 0, Length: 95, Exceptions: 0)Total transferred: 8696312 bytes  ## 從伺服器接收的byte個數,包含http頭HTML transferred: 8610757 bytes  ## 從伺服器接收的html文檔的總個數Requests per second: 14.49 [#/sec] (mean) ##每秒處理的請求書14.49 = 100 / 6.901Time per request: 690.140 [ms] (mean) ##單一請求的處理時間(用戶端感知的時間)Time per request: 69.014 [ms] (mean, across all concurrent requests) ##每個請求的處理時間(加上並發), 側重於看伺服器端的處理能力Transfer rate: 1230.55 [Kbytes/sec] received ##傳輸速率

Connection Times (ms)
              min  mean[+/-sd] median   maxConnect:        1   64 421.1      4    3000Processing:    11  615 1164.2     62    3146Waiting:        3  253 765.6     27    3062Total:         12  679 1214.4     63    3151    ##最快的請求回應時間是12ms, 最長的是3151msPercentage of the requests served within a certain time (ms) ## 給定時間內得到響應的請求數(百分比) 50% 63   ## 63ms內50%的請求得到了響應 66% 142 75% 164 80% 3033 90% 3107 95% 3133 98% 3141 99% 3151 100% 3151 (longest request)

ab工具雖然是apache用來給自己做測試用,也可以用來測試其他版本的伺服器。功能上ab比較完整,支援多個參數,撿幾個常用的介紹一下。

-k 啟用 KeepAlive, 一個會話裡發起多個請求。-i  發起HEAD請求,而不是GET請求

其他的參數用到的時候在解釋吧。

我在測試自己寫的簡單伺服器時會發現出一個錯誤:

Benchmarking 127.0.0.1 (be patient)...apr_socket_recv: 遠程主機強迫關閉了一個現有的串連。 (730054)

查了一下資料, 需要加上-k的參數來解決。

apache 的ab 工具

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.