apache ab概述

來源:互聯網
上載者:User

標籤:admin   4.0   測試   exe   調用   響應   log   測試的   lib   

一、apache ab 簡介

apache ab是apache下的小的效能測試工具

 

二、apache ab 路徑

linux下apache的安裝方式:

1、yum安裝的apache ab 路徑:cd /usr/sbin/

2、rpm安裝的apache ab 路徑:cd /opt/lampp/bin

 

三、apache ab查看和使用簡介

1、apache ab查看:

[[email protected] ~]# cd /opt/lampp/
[[email protected] lampp]# ls
apache2 ctlscript.sh htdocs info licenses manual php RELEASENOTES uninstall
bin docs icons lampp logs modules phpmyadmin sbin uninstall.dat
build error img lib man mysql proftpd share var
cgi-bin etc include libexec manager-linux.run pear properties.ini temp xampp
[[email protected] lampp]# cd bin
[[email protected] bin]# ll ab
-rwxr-xr-x. 1 root root 48408 2月 13 2014 ab
[[email protected] bin]# ./ab  → 查看協助
./ab: wrong number of arguments
Usage: ./ab [options] [http[s]://]hostname[:port]/path → 標識使用方式
Options are:
-n requests Number of requests to perform → 執行的請求數
-c concurrency Number of multiple requests to make at a time → 一次發出請求的數量

。。。 。。。

。。。 。。。

 

2、apache ab使用:

[[email protected] bin]# ./ab -n 1000 -c 10 http://sports.163.com/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking sports.163.com (be patient)
Completed 100 requests
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: openresty
Server Hostname: sports.163.com
Server Port: 80

Document Path: /
Document Length: 415744 bytes

Concurrency Level: 10  → 10個並發
Time taken for tests: 70.788 seconds → 10個並發發送1000次請求耗時(70.788 seconds*10/10並發=Time per request: 707.875 [ms] (mean) → 平均每次請求的回應時間)
Complete requests: 1000 → 請求的次數
Failed requests: 0 → 失敗的請求數

Non-2xx response: 0 → 非2開頭的請求數,2xx http請求狀態代碼
Total transferred: 416130766 bytes
HTML transferred: 415744000 bytes
Requests per second: 14.13 [#/sec] (mean)
Time per request: 707.875 [ms] (mean) → 平均每次請求的回應時間
Time per request: 70.788 [ms] (mean, across all concurrent requests) → 伺服器的平均回應時間,不包含發送請求的時間(tps)
Transfer rate: 5740.81 [Kbytes/sec] received

Connection Times (ms)
                       min   mean(平均耗時)[+/-sd](標準方差)   median(中間值)   max(最大耗時)
Connect:          21       59                   21.2                     59                 352    → 串連伺服器耗時(線程池排隊)
Processing:      475     646                  93.6                     635               1744  → 請求處理耗時
Waiting:          27       86                   69.7                     76                 713    →等待處理耗時 
Total:             527     706                  94.0                     689               1805   →平均每次請求的回應時間

Percentage of the requests served within a certain time (ms)
50%     689 →50%的使用者回應時間小於689ms
66%    714
75%    728
80%    742
90%    785
95%    855
98%    949
99%   1142
100% 1805 (longest request)

 

四、apache ab和loadrunner的效能測試結果比較

測試人員使用lr對某系統的某功能測試得出tps=100,開發用apache ab測相同系統的相同功能得出tps=3000,為什麼使用兩個測試載入器相差那麼大?

別人測試結果和自己的測試結果不一樣,關注如下:

1、測試環境(測試環境/開發環境);

2、資料量;

3、測試的是否是同一個系統功能;

4、測試載入器不一樣。

apache ab只發送請求不接收伺服器返回結果,發送到伺服器的狀態值為200,就認為請求成功結束了

loadrunner發請求後,會接收伺服器返回結果(同理伺服器返回成功會有個2xx的狀態代碼),這個請求才算結束

使用apache ab進行效能測試時候,對tps很大程度取決於CPU的核心數,效能好的伺服器通過apache ab進行效能測試,有的時候得出的測試結果會相差較大

linux top命令,可以查看系統cpu的核心數

所以apache ab會比lr快很多

 

五、什麼時候使用apache ab

1、開發測試效能會用apache ab

2、看看伺服器是否支援10W個tps。

Controller應與Load Generator分開,若測試需要的vu數,超過單負載機所能產生的vu數,則負載機本身將成為效能瓶頸,這是不合理的。例如,負載機記憶體512M,一個vu佔2.5M,則單台負載機只能產生200vu,若需測試500vu,一台controller調用多台Generator,要考慮負載平衡問題,頻寬問題。

 

六、如何判斷apache ab請求是否成功

1、lr可以用檢查點判斷請求是否成功

2、如何判斷apache ab請求是否成功:

①通過這個"Usage: ./ab [options] [http[s]://]hostname[:port]/path → 標識使用方式"命令,列印出來的響應資訊中,沒有Non-2xx response: 0;

②檢查伺服器列印的日誌狀態是否為2xx/3xx狀態代碼。

 

 

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.