CentOS로 weighttp 구축

5468 단어 benchmark
http 서버의 부하 테스트용 도구를 찾을 때 IIJ 사이트에 weighttp라는 도구를 소개했기 때문에 시험해 봤습니다.환경이 CentOS 7인지 확인합니다.

libev 설치


weighttp에서libev를 사용하기 때문에 epel 창고를 추가한 후에libev와libev-devel을 설치합니다.
$ yum install -y epel-release
$ yum install libev libev-devel -y

weighttp의 원본 코드 가져오기


github에서 원본 코드를 얻습니다.
$ cd /usr/local/src
$ git clone https://github.com/lighttpd/weighttp.git

weighttp 구축 설치


weighttp의 구축과 설치는waf를 사용하여 다음과 같이 진행한다.
$ cd weighttp
$ ./waf configure
Checking for program gcc,cc              : ok /usr/bin/gcc
Checking for program cpp                 : ok /usr/bin/cpp
Checking for program ar                  : ok /usr/bin/ar
Checking for program ranlib              : ok /usr/bin/ranlib
Checking for gcc                         : ok
Checking for library ev                  : ok
Checking for header ev.h                 : ok
Checking for library pthread             : ok
Checking for header pthread.h            : ok
Checking for header unistd.h             : ok
Checking for header stdint.h             : ok
Checking for header fcntl.h              : ok
Checking for header inttypes.h           : ok
'configure' finished successfully (2.184s)

$ ./waf build
Waf: Entering directory `/usr/local/src/weighttp/build'
[1/4] cc: src/client.c -> build/default/src/client_1.o
[2/4] cc: src/weighttp.c -> build/default/src/weighttp_1.o
[3/4] cc: src/worker.c -> build/default/src/worker_1.o
[4/4] cc_link: build/default/src/client_1.o build/default/src/weighttp_1.o build/default/src/worker_1.o -> build/default/weighttp
Waf: Leaving directory `/usr/local/src/weighttp/build'
'build' finished successfully (0.911s)

$ ./waf install
Waf: Entering directory `/usr/local/src/weighttp/build'
* installing build/default/weighttp as /usr/local/bin/weighttp
Waf: Leaving directory `/usr/local/src/weighttp/build'
'install' finished successfully (0.016s)

동작 확인


구축에 성공하면 동작을 확인합니다.
우선, 파라미터가 실행되지 않고 usage에서 명령의 형식을 확인합니다.
$ weighttp
weighttp - a lightweight and simple webserver benchmarking tool

error: missing url argument

weighttp <options> <url>
  -n num   number of requests    (mandatory)
  -t num   threadcount           (default: 1)
  -c num   concurrent clients    (default: 1)
  -k       keep alive            (default: no)
  -6       use ipv6              (default: no)
  -H str   add header to request
  -h       show help and exit
  -v       show version and exit

example: weighttpd -n 10000 -c 10 -t 2 -k -H "User-Agent: foo" localhost/index.html
마지막으로 명령의 실행 예시를 표시하지만, 왜 명령 이름이 틀렸는지 모르겠습니다.
디스플레이 형식을 참고하여 localhost의 httpd에서 weighttp를 실행한 후 다음과 같은 결과를 출력합니다.
$ weighttp -n 10000 -c 10 -t 2 -k -H "User-Agent: foo" localhost/noindex/css/open-sans.css
weighttp - a lightweight and simple webserver benchmarking tool

starting benchmark...
spawning thread #1: 5 concurrent requests, 5000 total requests
spawning thread #2: 5 concurrent requests, 5000 total requests
progress:  10% done
progress:  20% done
progress:  30% done
progress:  40% done
progress:  50% done
progress:  60% done
progress:  70% done
progress:  80% done
progress:  90% done
progress: 100% done

finished in 1 sec, 419 millisec and 293 microsec, 7045 req/s, 36911 kbyte/s
requests: 10000 total, 10000 started, 10000 done, 10000 succeeded, 0 failed, 0 errored
status codes: 10000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 53646048 bytes total, 2836048 bytes http, 50810000 bytes data
또한httpd의 로그 파일을 확인한 후 weighttp에서 온 접근 로그를 기록했습니다.
$ tail /var/log/httpd/access_log
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
127.0.0.1 - - [23/May/2015:19:11:10 +0900] "GET /noindex/css/open-sans.css HTTP/1.1" 200 5081 "-" "foo"
::1 - - [23/May/2015:19:11:11 +0900] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
::1 - - [23/May/2015:19:11:12 +0900] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
::1 - - [23/May/2015:19:11:13 +0900] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
문제 없이 일하는 것 같다

좋은 웹페이지 즐겨찾기