관리 메뉴

Sysops Notepad

[linux] AB(Apache http server Benchmarking tool)를 활용한 벤치마킹 테스트 본문

업무/etc

[linux] AB(Apache http server Benchmarking tool)를 활용한 벤치마킹 테스트

sysops 2019. 2. 19. 11:11



1. ab란?

- Apache HTTP server Benchmarking Tool

- Apache 응답속도를 체크하는 벤치마팅 툴



2. 사용법


# yum install httpd-tools


# ab  -c 클라이언트수  -n 요청수  -t 시간  URL


# ab  -c 100 -n 200 -t 60 https://www.naver.com



3. 옵션


  -n requests  Number of requests to perform : 벤치마킹을 위한 요청수

    -c concurrency Number of multiple requests to make : 하나의 요청당 체크할 다중 요구수 (기본값 : 1)

    -t timelimit Seconds to max. wait for responses : 제한시간 

    -p postfile  File containg data to POST         : POST 할 파일 지정 (ex> -g result.plot)

    -T content-type Content-type header for POSTing

    -v verbosity    How much troubleshooting info to print : 자세한 헤더정보 출력 (유용함) 

    -w              Print out results in HTML tables         : HTML 형태로 출력 (유용함) 

    -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: zop'

                       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.

    -g filename     Output collected data to gnuplot format file.

    -e filename     Output CSV file with percentages served

    -h              Display usage information (this message)



4. 결과 


- Server Software : 아파치 버전


- Server Host Name : 서버 호스트명


- Server Port : 포트 번호


- Document Path : 웹문서 위치


- Time take for tests : 테스트 시간


- Document Length : 문서의 크기


- Complete requests : 응답 완료한 요청 수


- Failed requests : 응답실패한 요청 수


- Broken pipe errors : 연결이 끊긴 수


- Total transferred : 총 전송 바이트 수


- HTTP transferred : 총 전송 HTML 바이트 수


- Requests per second : 초당 응답 요청 수


- Time per requests : 요청 당 응답시간


- Transfer rate : 초당 전송 용량



5. etc


gnuplot 데이터를 활용한 요청 로그 그래프 생성


# ab -n 100 -c 10 -g result.plot https://www.naver.com


# vi script.plot

# 터미널 사이즈 조정

set terminal png size 1024,768


# 가로, 세로 비율

set size 1,0.5


# 결과 파일 설정

set output "result.png"


# 범례/key 위치

set key left top


# y축 grid line

set grid y


# Label the x-axis

set xlabel 'requests'

# Label the y-axis

set ylabel "response time (ms)"


# Tell gnuplot to use tabs as the delimiter instead of spaces (default)

set datafile separator '\t'


# Plot the data

plot "result.plot" every ::2 using 5 title 'response time' with lines  

exit  


# gnuplot script.plot


starttime : request가 시작된 시간

seconds : starttime을 unix timestamp로 표현

ctime : connection 시간으로 request를 write하기 위해 서버와 socket을 여는 시간

dtime : processing 시간 -> 결과를 반환받기 위해 wait하는 시간 + 서버 작업 시간 + 결과 반환 시간.

dtime = ttime – ctime

ttime : request가 전체 수행된 시간(ttime = ctime + dtime)

wait : request를 보내고나서 response를 받기 전까지 서버사이드에서 처리되는 시간

network 시간 = dtime – wait



참고: 

https://duronex.tistory.com/1

http://blog.hkwon.me/ab-apache-http-server-benchmarking-tool/



Comments