본문 바로가기

리눅스

ab(Apache Bench) tools

728x90

ab(Apache Bench) tools

ab - Apache HTTP 서버 벤치마킹 도구

ab 버전

$ ab -V
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/

ab 명령어

더보기

---

$ ab -h
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
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234'. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

---

ab tools 설치

  • ubuntu
apt install -y apache2-utils
  • centos / amzn2
yum install -y httpd-tools

ab 명령어의 기본 구문

ab -n [요청 횟수] -c [동시 접속 수] [URL]
  • [요청 횟수] : HTTP 서버에 전송할 요청의 횟수를 지정합니다.
  • [동시 접속 수] : 동시에 처리할 수 있는 요청의 최대 수를 지정합니다.
  • [URL] : HTTP 서버에 전송할 요청 URL을 지정합니다.

ab 테스트 명령어

###ab -n 요청 수 -c 동시 클라이언트 수 -t 시간 URL
ab -n 10 -c 1 https://www.google.com/
$ ab -n 10 -c 1 https://www.google.com/
This is ApacheBench, Version 2.3 <$Revision: 1874286 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.google.com (be patient).....done


Server Software:        gws
Server Hostname:        www.google.com
Server Port:            443
SSL/TLS Protocol:       TLSv1.2,ECDHE-ECDSA-AES128-GCM-SHA256,256,128
Server Temp Key:        ECDH P-256 256 bits
TLS Server Name:        www.google.com

Document Path:          /
Document Length:        13054 bytes

Concurrency Level:      1
Time taken for tests:   2.426 seconds
Complete requests:      10
Failed requests:        9
   (Connect: 0, Receive: 0, Length: 9, Exceptions: 0)
Total transferred:      139652 bytes
HTML transferred:       130582 bytes
Requests per second:    4.12 [#/sec] (mean)
Time per request:       242.585 [ms] (mean)
Time per request:       242.585 [ms] (mean, across all concurrent requests)
Transfer rate:          56.22 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      129  133   1.8    134     134
Processing:   105  110   3.3    110     115
Waiting:      100  104   3.4    104     111
Total:        237  243   3.8    244     250

Percentage of the requests served within a certain time (ms)
  50%    244
  66%    244
  75%    244
  80%    246
  90%    250
  95%    250
  98%    250
  99%    250
 100%    250 (longest request)
728x90

ab 성능 테스트

ab 테스트 명령

ab -n 300 -c 300 https://www.scbyun.com/
$ ab -n 300 -c 300 https://www.scbyun.com/ | egrep 'Concurrency Level|Time taken for tests|Complete requests|Failed requests|Requests per second|Time per request|Transfer rate'
Concurrency Level:      300
Time taken for tests:   16.899 seconds
Complete requests:      300
Failed requests:        0
Requests per second:    17.75 [#/sec] (mean)
Time per request:       16899.169 [ms] (mean)
Time per request:       56.331 [ms] (mean, across all concurrent requests)
Transfer rate:          2374.39 [Kbytes/sec] received

ab 테스트 지표

  • 명령어를 입력한 후, ApacheBench는 HTTP 서버에 대한 요청을 보내며, 이에 대한 응답 시간, 처리 속도 등의 결과를 출력합니다.
  • 결과 중에서도 특히, Transactions per second (TPS)와 Time per request는 HTTP 서버의 처리 성능을 평가하는 데 중요한 지표입니다.
  1 2 3 4 5 6
요청 수
(requests)
1 10 100 100 100 100
동시성 수준
(Concurrency Level)
1 10 10 20 50 100
테스트 소요 시간(s)
(Time taken for tests)
0.279 0.980 6.059 6.165 6.288 6.159
실패한 요청
(Failed requests)
0 0 0 0 0 0
초당 요청 수
(Requests per second)
3.58 10.20 16.51 16.22 15.90 16.24
요청당 평균 소요 시간(ms) #1
(Time per request)
279.310 980.295 605.860 1233.061 3143.972 6159.137
요청당 평균 소요 시간(ms) #2
(Time per request)
279.310 98.030 60.586 61.653 62.879 61.591
전송 속도
(Transfer rate)
           
  • 초당 요청 수 = 100 / 6.059 = 16.51
  • #1 Time per request (mean) = 동시 요청을 처리하는데 걸린 평균 시간(10 * 6.059 * 1000 / 100 = 605.860ms)
  • #2 Time per request (mean, across all concurrent requests) = 단일 요청을 처리하는데 걸린 평균 시간(6.059 * 1000 / 100 = 60.586ms)

 

참고URL

- ab : 아파치 웹서버 성능검사 도구(https://httpd.apache.org/docs/2.4/en/programs/ab.html, https://httpd.apache.org/docs/2.4/programs/ab.html)

- ab tools 에러 : https://scbyun.com/993

 

728x90