apache ab概述

1、apache ab 簡介php

apache ab是apache下的小的性能測試工具mysql

 

2、apache ab 路徑linux

linux下apache的安裝方式:sql

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

二、rpm安裝的apache ab 路徑:cd /opt/lampp/bin服務器

 

3、apache ab查看和使用簡介併發

一、apache ab查看:負載均衡

[root@besttest ~]# cd /opt/lampp/
[root@besttest 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
[root@besttest lampp]# cd bin
[root@besttest bin]# ll ab
-rwxr-xr-x. 1 root root 48408 2月 13 2014 ab
[root@besttest 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 → 一次發出請求的數量工具

。。。 。。。性能

。。。 。。。

 

二、apache ab使用:

[root@besttest 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)

 

4、apache ab和loadrunner的性能測試結果比較

測試人員使用lr對某系統的某功能測試得出tps=100,開發用apache ab測相同系統的相同功能得出tps=3000,爲何使用兩個測試工具相差那麼大?

別人測試結果和本身的測試結果不同,關注以下:

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

二、數據量;

三、測試的是不是同一個系統功能;

四、測試工具不同。

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

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

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

linux top命令,能夠查看系統cpu的核數

因此apache ab會比lr快不少

 

5、何時使用apache ab

一、開發測試性能會用apache ab

二、看看服務器是否支持10W個tps。

Controller應與Load Generator分開,若測試須要的vu數,超過單負載機所能產生的vu數,則負載機自己將成爲性能瓶頸,這是不合理的。例如,負載機內存512M,一個vu佔2.5M,則單臺負載機只能產生200vu,若需測試500vu,一臺controller調用多臺Generator,要考慮負載均衡問題,帶寬問題。

 

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

一、lr能夠用檢查點判斷請求是否成功

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

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

②檢查服務器打印的日誌狀態是否爲2xx/3xx狀態碼。

 

相關文章
相關標籤/搜索