처음에는 Graphite, DBInfluxDB, OpenTSDB 등을 지원하는 오픈소스 대시보드 도구로 개발
메트릭 정보를 시각화하고 대시보드를 구성한다는 큰 틀은 여전히 변함이 없습니다만, AWS CloudWatch, Azure Monitor와 같은 클라우드 데이터 소스를 비롯해 Loki나 ElasticSearch 등을 기반으로 로그 데이터를 지원하는 등 더 많은 데이터 소스를 지원
엔터프라이즈 플랜에서는 Splunk, New Relic, AppDynamics, Oracle, Dynatrace, ServiceNow, DataDog 등의 외부 서비스들과 통합도 지원
Grafana는 현재 Grafana Labs에서 개발
Grafana LAB은 Grafana와 Loki, Tanka 등의 애플리케이션을 오픈소스를 개발하고 있는 회사
Grafana는 Paypal, ebay, Intel, rackspace, Video, TED, Digital Ocean, Bloomberg 등 다양한 기업에서 활용
$ ab
Usage: ab [options] [http[s]://]hostname[:port]/path
AB 명령어 자주 사용하는 옵션
옵션
설명
-n
- 성능을 검사하기위해 보내는 요청수. -요청을 한번만 보내기 때문에 일반적인 성능 검사 결과를 얻을 수 없음
-c
-동시에 요청하는 요청수 -기본적으로 한번에 한 요청만을 보냄
-C
-Cookie 헤더 사용
-H
-요청에 헤더 추가
-i
-GET 메소드 대신 HEAD 메소드 요청
-k
-KeepAlive 사용 -동적 페이지는 Centent-Length 헤더 내용을 미리 작성할 수 없기 때문에 -k KeepAlive 옵션이 동작하지 않음
-p
-POST 메소드 요청
-g
-측정한 모든 값을 'gnuplot' 혹은 TSV(Tab separate values, 탭으로 구분한 값) 파일에 기록 -라벨은 output 파일의 첫번째 라인을 참고
-t
-성능을 검사하는 최대 초단위 시간. -내부적으로 -n 50000을 가정 -정해진 시간동안 서버 성능을 검사할때 사용 -기본적으로 시간 제한 없이 검사
-v
-출력 수준을 지정 -4 이상이면 헤더에 대한 정보를 출력 -3 이상이면 (404, 202, 등) 응답코드를 출력 -2 이상이면 경고(warning)와 정보(info)를 출력
-A
-프록시를 통해 BASIC Authentication 정보를 제공 -:로 구분한 사용자명과 암호를 base64 인코딩하여 전송
-X
-proxy[:port] 프록시 서버를 사용하여 요청
AB 명령어에서 헷갈리는 대표적인 옵션 -c 옵션에 대한 설명
-c 옵션이 기본적으로 다른 부하툴과는 다른게 동작 → 3개의 프로세스(쓰레드)가 10개씩 요청하는 것이 아니라 3개의 풀을 가지고 10번 요청을 진행 $ ab -n 10 -c 3 http://www.google.com
-c옵션에서 숫자는 pool 개념으로 보면 됨 [1, 2, 3]
-c 옵션에 3을 선언하였으면, 시작을 3개의 요청을 시작했고, 만약 2번이 먼저 종료됐으면 2번을 4번으로 대체 요청 [1, 4, 3]
1번이 종료되면 5번으로 대체 요청 [5, 4, 3]
3번이 종료되면 6번이 대체 요청 [5, 4, 6]
10개의 요청을 순차로 처리함
AB 명령어 전체 옵션
$ 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
-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
-l Accept variable document length (use this for dynamic pages)
-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.
-m method Method name
-h Display usage information (this message)
-I Disable TLS Server Name Indication (SNI) extension
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol
(SSL2, TLS1, TLS1.1, TLS1.2 or ALL)
Time per request: 16.00 【ms】 (mean, across all concurrent requests)
-요구에 응답한 시간
Transfer rate: 4533.69 【Kbytes/sec】 received
-초당 전송 가능한 용량
Client 측 ab 부하테스트 호출 테스트
1. 요청 400, 동시접속자 1
$ ab -n 400 -c 1 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 1
Time taken for tests: 10.191 seconds ### 총 시간
Complete requests: 400
Failed requests: 0 ### 에러 수
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 39.25 [#/sec] (mean) ==> 초당 처리 Request 수
Time per request: 25.476 [ms] (mean) ==> Request 당 처리 시간
Time per request: 25.476 [ms] (mean, across all concurrent requests)
Transfer rate: 9.31 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 21 25 5.7 23 59
Waiting: 21 25 5.7 23 59
Total: 21 25 5.7 23 59
Percentage of the requests served within a certain time (ms)
50% 23
66% 25
75% 28
80% 28
90% 30
95% 37
98% 44
99% 53
100% 59 (longest request)
2. 요청 400, 동시접속자 2
$ ab -n 400 -c 2 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 2
Time taken for tests: 10.103 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 39.59 [#/sec] (mean)
Time per request: 50.514 [ms] (mean)
Time per request: 25.257 [ms] (mean, across all concurrent requests)
Transfer rate: 9.40 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 22 50 16.1 49 152
Waiting: 22 50 16.1 49 152
Total: 22 50 16.1 49 152
Percentage of the requests served within a certain time (ms)
50% 49
66% 53
75% 58
80% 63
90% 73
95% 77
98% 87
99% 94
100% 152 (longest request)
3. 요청 400, 동시접속자 10
$ ab -n 400 -c 10 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 10
Time taken for tests: 10.262 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 38.98 [#/sec] (mean)
Time per request: 256.540 [ms] (mean)
Time per request: 25.654 [ms] (mean, across all concurrent requests)
Transfer rate: 9.25 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 24 254 111.9 240 681
Waiting: 24 254 111.9 240 681
Total: 24 254 111.9 241 682
Percentage of the requests served within a certain time (ms)
50% 241
66% 289
75% 338
80% 364
90% 408
95% 443
98% 500
99% 560
100% 682 (longest request)
4. 요청 400, 동시접속자 20
$ ab -n 400 -c 20 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 20
Time taken for tests: 10.454 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 38.26 [#/sec] (mean)
Time per request: 522.718 [ms] (mean)
Time per request: 26.136 [ms] (mean, across all concurrent requests)
Transfer rate: 9.08 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 3
Processing: 24 514 273.4 515 1592
Waiting: 24 514 273.5 515 1592
Total: 25 514 273.4 515 1592
Percentage of the requests served within a certain time (ms)
50% 515
66% 624
75% 676
80% 711
90% 822
95% 996
98% 1230
99% 1284
100% 1592 (longest request)
5. 요청 400, 동시접속자 50
$ ab -n 400 -c 50 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 50
Time taken for tests: 10.614 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 37.69 [#/sec] (mean)
Time per request: 1326.737 [ms] (mean)
Time per request: 26.535 [ms] (mean, across all concurrent requests)
Transfer rate: 8.94 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 2
Processing: 25 1264 411.7 1265 2826
Waiting: 23 1264 411.7 1265 2826
Total: 25 1264 411.5 1266 2827
Percentage of the requests served within a certain time (ms)
50% 1266
66% 1418
75% 1506
80% 1561
90% 1780
95% 1948
98% 2222
99% 2323
100% 2827 (longest request)
6. 요청 400, 동시접속자 100
$ ab -n 400 -c 100 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 100
Time taken for tests: 10.580 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 37.81 [#/sec] (mean)
Time per request: 2645.001 [ms] (mean)
Time per request: 26.450 [ms] (mean, across all concurrent requests)
Transfer rate: 8.97 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.4 0 5
Processing: 28 2377 679.8 2498 3706
Waiting: 23 2376 679.8 2498 3706
Total: 29 2378 678.8 2499 3706
Percentage of the requests served within a certain time (ms)
50% 2499
66% 2675
75% 2807
80% 2840
90% 2995
95% 3176
98% 3394
99% 3534
100% 3706 (longest request)
7. 요청 400, 동시접속자 200
$ ab -n 400 -c 200 http://[도메인]:80/while.jsp
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/
Benchmarking [도메인] (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 400 requests
Server Software:
Server Hostname: [도메인]
Server Port: 80
Document Path: /while.jsp
Document Length: 2 bytes
Concurrency Level: 200
Time taken for tests: 9.756 seconds
Complete requests: 400
Failed requests: 0
Write errors: 0
Total transferred: 97200 bytes
HTML transferred: 800 bytes
Requests per second: 41.00 [#/sec] (mean)
Time per request: 4877.980 [ms] (mean)
Time per request: 24.390 [ms] (mean, across all concurrent requests)
Transfer rate: 9.73 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 3 3.2 2 9
Processing: 32 3750 1525.0 4534 6111
Waiting: 22 3750 1524.9 4528 6111
Total: 32 3753 1522.0 4535 6111
Percentage of the requests served within a certain time (ms)
50% 4535
66% 4719
75% 4896
80% 4978
90% 5173
95% 5265
98% 5612
99% 5727
100% 6111 (longest request)
테스트 시나리오 결과 해석
1. 본 테스트의 시나리오는 전체 요청 수인 400 Request를 처리
2. 동시 요청이 1, 2, 10, 20, 50, 100, 200일 경우 성능의 변화를 모니터링하는 것
요청
동시 접속
총소요시간(Sec)
실패
초당처리속도
개별처리속도(Sec)
400
1
10.191
0
39.25
0.025476 / 1
400
2
10.103
0
39.59
0.050514 / 2
400
10
10.262
0
38.98
0.25654 / 10
400
20
10.454
0
38.26
0.522718 / 20
400
50
10.614
0
37.69
1.326737 / 50
400
100
10.58
0
37.81
2.645001 / 100
400
200
9.756
0
41
4.87798 / 200
3. 동시 접속자가 늘어나도 초당 처리 속도는 비슷하게 측정 → 400 / 200 (총 요청 수 / 동시 요청 수)일 경우 초당 처리 요청이 가능 많음
4. Single Instance의 처리 속도 아래 표의 결과는 LoadBalancer를 두고 처리할 성능 지표
요청
동시 접속
총소요시간(Sec)
실패
초당처리속도
개별처리속도(Sec)
400
200
9.163
0
43.65
2.811523
5. 한대의 서버에서 테스트가 힘들면, 서버의 대수를 늘리면 됨
6. 수동의 작업들을 완전히 자동화 해주는 오토스켈링(AutoScaling)과 ELB가 만나게 되면 엄청난 시너지 효과를 내타냄
개발자가 개발하면서 동시에 테스트해 정량적 데이터를 기준으로 성능 개선이 가능한 점이 편리함
siege는 유닉스 기반의 명령행 기반 툴으로, GNU GPL 오픈소스 라이선스를 따르기 때문에 사용, 수정, 배포가 모두 무료
siege는 단일 URL의 부하 테스트는 물론 많은 URL을 메모리로 불러들여 사용자가 설정한 시뮬레이션 유저만큼의 부하를 동시에 테스트할 수 있음
기록된 총 히트수와 전송된 바이트수, 반응시간, 병행성(Concurrency), 리턴 상태 등을 보여주며, HTTP 1.0/1.1 프로토콜, GET/POST 디렉티브, 쿠키, 트랜잭션 로깅, 기본적인 인증 등을 지원
1. Linux에서 siege HTTP 부하 테스트 유틸리티 설치
1.1. CentOS/RHEL에서 siege 설치
$ yum groupinstall 'Development Tools'
$ yum install -y epel-release
$ yum install -y siege
# 설치 후 siege 버전 확인
$ siege --version
SIEGE 4.1.1
Copyright (C) 2021 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
1.2. wget 명령어를 사용하여 최신 버전의 siege를 다운로드 후에 설치
# 최신 버전은 siege 다운로드 및 압축 해제
$ wget http://download.joedog.org/siege/siege-latest.tar.gz
$ tar -zxvf siege-latest.tar.gz
$ cd siege-*/
# 컴파일 및 설치
$ ./configure --prefix=/usr/local --with-ssl=/usr/bin/openssl
$ make
$ make install
# 설치된 siege 명령어 위치 확인
$ which siege
/usr/local/bin/siege
# 설치 후 siege 버전 확인
$ siege --version
SIEGE 4.1.5
Copyright (C) 2022 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
2. Linux에서 Siege HTTP로드 테스트 유틸리티 구성
설치를 완료하면 Siege 구성 파일 조정 가능
yum을 통해 siege 명령어를 다운받는 경우 생성 구성 파일 : /etc/siege/siegerc
소스에서 패키지를 빌드로 설치한 경우 생성 구성 파일 ; /usr/local/bin/siege.config
# ~/.siege/siege.conf에있는 siege.conf 파일이 생성
$ siege.config
siegerc 파일 또는 siege.conf 파일 확인 → siege이 1 분에 25 명의 동시 사용자를 모방
- 테스트를 실행할 시간 설정 - 테스트 실행 시간 단윈 : S, M, H - 예시 : -t 10S → 10초 동안 테스트 지정
-d
- 각 사용자 요청 사이의 시간 지연 지정
-b
- 요청 사이에 지연이 없도록 설정
-i
- user 시뮬레이션 - 임의의 URL을 적중하는 데 사용
-f
- 지정된 파일에서 URL을 테스트
-l
- 로그 파일 지정
-H
- 요청할 헤더를 추가함
-A
- 사용자 에이전드(User-Agent)를 지정
-T
- 요청의 Content-Type을 지정
--no-parser
- HTML 페이지 parser를 off
--no-follow
- HTTP 리디렉션을 따르지 않음
4. siege 출력 결과 설명
구분
설명
Transactions
- HTTP 요청횟수 -예상되는 히트 수보다 더 많이 출력 가능 -리다이렉션이나 인증문제로 2개의 히트를 하나로 계산하지 않음 → HTTP 사용을 따르는 브라우저 동작을 모방
Availability
-서버가 성공적으로 처리하는 소켓 연결의 확률 -성공 횟수/연결시도 횟수 * 100 ( 400, 500 에러 제외)
Elapsed time
-전체 siege 테스트 하는데 걸리는 시간
Data transferred
-siege가 시뮬레이션 된 브라우저에 전송하는 전체 데이터량 -전체 데이터는 컨텐츠 뿐만 아니라 헤더 정보까지 포함 -헤더 정보를 포함하기에 , siege가 표시하는 전체 데이터량은 서버가 전달하는 양보다 큼 -특정 설정 파일에 있는 임의의 URL을 사용하는 internet 모드로 설정된 상황에서는 전체 전송 데이터량은 동작할 때마다 각각 값이 달라짐
Response time
-siege가 시뮬레이션 된 브라우저의 각 요청에 대해 걸린 평균 응답시간
Transaction rate
-서버가 초당 처리할수 있는 트랜잭션 개수
Throughput
-서버에서 시뮬레이션 된 브라우저로 초당 전송되는 평균바이트단위의 데이터량
Concurrency
-동시 연결할수 있는 평균 개수이고, 증가할때마다 서버의 성능은 저하됨
Successful transactions
-트랜젝션 성공 횟수 -서버가 400 이하의 응답코드를 반환하는 횟수
Failed transactions
-트랜젝션 실패 횟수 -서버가 400 혹은 그이상의 응답코드를 반환하는 횟수 -타임아웃 횟수를 포함한 소켓 연결이 실패된 트랜잭션의 합계도 나타냄
Longest transaction
-모든 트랜잭션중 단일 트랜잭션 처리에 걸린 가장 긴시간
Shortest transaction
-모든 트랜잭션중 단일 트랜잭션 처리에 걸린 가장 짧은 시간
5. siege 테스트
5.1. 1명의 가상의 유저가 1초동안 무제한으로 계속해서 접속 부하 테스트 (지연 X)
$ siege -c1 -t1s http://[domain]/test/upload/1.jpg
** SIEGE 4.1.1
** Preparing 1 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
....생략....
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.00 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
Lifting the server siege...
Transactions: 95 hits
Availability: 100.00 %
Elapsed time: 0.57 secs
Data transferred: 13.85 MB
Response time: 0.01 secs
Transaction rate: 166.67 trans/sec
Throughput: 24.29 MB/sec
Concurrency: 0.98
Successful transactions: 95
Failed transactions: 0
Longest transaction: 0.04
Shortest transaction: 0.00
5.2. 1명의 가상의 유저가 1초동안 1초 간격으로 계속해서 접속 부하 테스트 (가상 유저의 요청 간격은 1초)
$ siege -c1 -t1s -d 1 http://[도메인]/test/upload/1.jpg
** SIEGE 4.1.1
** Preparing 1 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.08 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.00 secs: 152849 bytes ==> GET /test/upload/1.jpg
Lifting the server siege...
Transactions: 2 hits
Availability: 100.00 %
Elapsed time: 0.34 secs
Data transferred: 0.29 MB
Response time: 0.04 secs
Transaction rate: 5.88 trans/sec
Throughput: 0.86 MB/sec
Concurrency: 0.24
Successful transactions: 2
Failed transactions: 0
Longest transaction: 0.08
Shortest transaction: 0.00
5.3. 10명의 가상의 유저가 1초동안 1초 간격으로 계속해서 접속 부하 테스트 (가상 유저의 요청 간격은 1초)
$ siege -c10 -t1s -d 1 http://[도메인]/test/upload/1.jpg
** SIEGE 4.1.1
** Preparing 10 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.00 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.05 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.00 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.00 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
Lifting the server siege...
Transactions: 16 hits
Availability: 100.00 %
Elapsed time: 0.34 secs
Data transferred: 2.33 MB
Response time: 0.03 secs
Transaction rate: 47.06 trans/sec
Throughput: 6.86 MB/sec
Concurrency: 1.47
Successful transactions: 16
Failed transactions: 0
Longest transaction: 0.05
Shortest transaction: 0.04
5.4. 10명의 가상의 유저가 10회 반복으로 접속 부하 테스트
$ siege -c10 -r 10 http://[도메인]/test/upload/1.jpg
** SIEGE 4.1.1
** Preparing 10 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.04 secs: 152849 bytes ==> GET /test/upload/1.jpg
...생략...
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
HTTP/1.1 200 0.01 secs: 152849 bytes ==> GET /test/upload/1.jpg
Transactions: 100 hits
Availability: 100.00 %
Elapsed time: 0.17 secs
Data transferred: 14.58 MB
Response time: 0.02 secs
Transaction rate: 588.24 trans/sec
Throughput: 85.75 MB/sec
Concurrency: 9.41
Successful transactions: 100
Failed transactions: 0
Longest transaction: 0.06
Shortest transaction: 0.00
5.5. 1명의 가상의 유저가 특정 파일의 URL을 읽어서 접속 부하 테스트
# dims_list.txt 파일에는 서로 다른 URL 있음(위 URL 묶음을 넣을 수 있음)
$ siege -c1 -r 40 -f dims_list.txt
** SIEGE 4.1.1
** Preparing 1 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.06 secs: 140803 bytes ==> GET /test/upload/1.jpg/dims/resize/500X500
HTTP/1.1 200 0.05 secs: 183271 bytes ==> GET /test/upload/2.jpg/dims/resize/500X500
HTTP/1.1 200 0.35 secs: 350565 bytes ==> GET /test/upload/3.jpg/dims/resize/500X500
HTTP/1.1 200 0.04 secs: 101547 bytes ==> GET /test/upload/4.jpg/dims/resize/500X500
...생략...
HTTP/1.1 200 0.04 secs: 151130 bytes ==> GET /test/upload/36.jpg/dims/resize/500X500
HTTP/1.1 200 0.04 secs: 130278 bytes ==> GET /test/upload/37.jpg/dims/resize/500X500
HTTP/1.1 200 0.05 secs: 161169 bytes ==> GET /test/upload/38.jpg/dims/resize/500X500
HTTP/1.1 200 0.04 secs: 150939 bytes ==> GET /test/upload/39.jpg/dims/resize/500X500
HTTP/1.1 200 0.04 secs: 133090 bytes ==> GET /test/upload/40.jpg/dims/resize/500X500
Transactions: 40 hits
Availability: 100.00 %
Elapsed time: 2.40 secs
Data transferred: 6.87 MB
Response time: 0.06 secs
Transaction rate: 16.67 trans/sec
Throughput: 2.86 MB/sec
Concurrency: 1.00
Successful transactions: 40
Failed transactions: 0
Longest transaction: 0.36
Shortest transaction: 0.03
5.6. 40명의 가상의 유저가 특정 파일의 URL을 읽어서 접속 부하 테스트
# dims_list.txt 파일에는 서로 다른 URL 있음(위 URL 묶음을 넣을 수 있음)
$ siege -c40 -r 1 -f dims_list.txt
** SIEGE 4.1.1
** Preparing 40 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.08 secs: 173928 bytes ==> GET /test/upload/11.jpg/dims/resize/500X500
HTTP/1.1 200 0.08 secs: 130312 bytes ==> GET /test/upload/5.jpg/dims/resize/500X500
HTTP/1.1 200 0.08 secs: 241077 bytes ==> GET /test/upload/28.jpg/dims/resize/500X500
HTTP/1.1 200 0.09 secs: 116310 bytes ==> GET /test/upload/12.jpg/dims/resize/500X500
HTTP/1.1 200 0.09 secs: 181265 bytes ==> GET /test/upload/14.jpg/dims/resize/500X500
...생략...
HTTP/1.1 200 0.21 secs: 200534 bytes ==> GET /test/upload/26.jpg/dims/resize/500X500
HTTP/1.1 200 0.22 secs: 249170 bytes ==> GET /test/upload/9.jpg/dims/resize/500X500
HTTP/1.1 200 0.41 secs: 360241 bytes ==> GET /test/upload/13.jpg/dims/resize/500X500
HTTP/1.1 200 0.47 secs: 350565 bytes ==> GET /test/upload/3.jpg/dims/resize/500X500
Transactions: 40 hits
Availability: 100.00 %
Elapsed time: 0.47 secs
Data transferred: 6.87 MB
Response time: 0.15 secs
Transaction rate: 85.11 trans/sec
Throughput: 14.63 MB/sec
Concurrency: 12.51
Successful transactions: 40
Failed transactions: 0
Longest transaction: 0.47
Shortest transaction: 0.08
5.7. 200명의 가상의 유저가 특정 파일의 URL을 읽어서 접속 부하 테스트
# 200_dims_list.txt 파일에 resize 크기만 다르게 하여서 200개 생성
$ siege -c200 -r 1 -f 200_dims_list.txt
** SIEGE 4.1.1
** Preparing 200 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200 0.11 secs: 22699 bytes ==> GET /test/upload/12.jpg/dims/resize/200X200
HTTP/1.1 200 0.12 secs: 218332 bytes ==> GET /test/upload/37.jpg/dims/resize/700X700
HTTP/1.1 200 0.13 secs: 25510 bytes ==> GET /test/upload/31.jpg/dims/resize/200X200
HTTP/1.1 200 0.16 secs: 130278 bytes ==> GET /test/upload/37.jpg/dims/resize/500X500
HTTP/1.1 200 0.16 secs: 27489 bytes ==> GET /test/upload/39.jpg/dims/resize/200X200
HTTP/1.1 200 0.22 secs: 131463 bytes ==> GET /test/upload/35.jpg/dims/resize/500X500
HTTP/1.1 200 0.26 secs: 31468 bytes ==> GET /test/upload/36.jpg/dims/resize/200X200
...생략...
HTTP/1.1 200 2.91 secs: 1531300 bytes ==> GET /test/upload/14.jpg/dims/resize/2100X2100
HTTP/1.1 200 2.93 secs: 1870440 bytes ==> GET /test/upload/2.jpg/dims/resize/2100X2100
HTTP/1.1 200 2.94 secs: 1286358 bytes ==> GET /test/upload/38.jpg/dims/resize/2100X2100
HTTP/1.1 200 3.11 secs: 350565 bytes ==> GET /test/upload/3.jpg/dims/resize/500X500
HTTP/1.1 200 3.26 secs: 621024 bytes ==> GET /test/upload/13.jpg/dims/resize/700X700
HTTP/1.1 200 3.31 secs: 68988 bytes ==> GET /test/upload/3.jpg/dims/resize/200X200
HTTP/1.1 200 3.60 secs: 360241 bytes ==> GET /test/upload/13.jpg/dims/resize/500X500
HTTP/1.1 200 3.64 secs: 609878 bytes ==> GET /test/upload/3.jpg/dims/resize/700X700
HTTP/1.1 200 4.56 secs: 1044667 bytes ==> GET /test/upload/3.jpg/dims/resize/1000X1000
HTTP/1.1 200 6.75 secs: 3148711 bytes ==> GET /test/upload/3.jpg/dims/resize/2100X2100
HTTP/1.1 200 7.96 secs: 3231253 bytes ==> GET /test/upload/13.jpg/dims/resize/2100X2100
Transactions: 200 hits
Availability: 100.00 %
Elapsed time: 7.98 secs
Data transferred: 100.42 MB
Response time: 1.60 secs
Transaction rate: 25.06 trans/sec
Throughput: 12.58 MB/sec
Concurrency: 40.20
Successful transactions: 200
Failed transactions: 0
Longest transaction: 7.96
Shortest transaction: 0.11
docker cp <container name>:<path> <host경로> 또는 docker cp <host경로> <container name>:<path> 명령어로 사용
# 실행할 이미지 확인
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test vol b00a026e35cd 51 minutes ago 133MB
locahost:5000/vol v1 b00a026e35cd 51 minutes ago 133MB
localhost:5000/vol v1 b00a026e35cd 51 minutes ago 133MB
test user 0e7f2d0690f8 2 hours ago 73.1MB
ubuntu latest 1318b700e415 5 hours ago 72.8MB
forestian/test web d19fbcd7480b 18 hours ago 133MB
nginx latest 08b152afcfae 4 days ago 133MB
registry latest 1fd8e1b0bb7e 3 months ago 26.2MB
# 테스트 켄터이너 실행
$ docker run --rm -d -it test:vol /bin/bash
# 실행하는 컨테이너 확인
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
df8bc7355db0 test:vol "/docker-entrypoint.…" 3 minutes ago Up 3 minutes 80/tcp wonderful_burnell
# 해당 명령어의 파일 없음
$ docker exec -it df8 ls /bin/ip
Error: No such container: test:vol
# web 이름을 가진 컨테이너에 host가 가지고 있는 /usr/sbin/ip 파일을 /bin/디렉토리 아래에 복사
$ docker cp /usr/sbin/ip df8:/bin/
# 해당 명령어의 파일이 정상적으로 복사됨 확인
$ docker exec -it df8 ls /bin/ip
/bin/ip
2. 변경된 컨테이너 file 조회
docker diff <container name> 명령어로 사용
이미지와 Container를 비교하여 변경된 파일 목록 출력
A → add
C → change
D → delete
변경된 컨테이너 file 조회 예시
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
df8bc7355db0 test:vol "/docker-entrypoint.…" 6 minutes ago Up 6 minutes 80/tcp wonderful_burnell
$ docker diff df8
C /bin
A /bin/ip
3. 변경된 컨테이너 이미지 생성 → 백업 이미지 생성
docker commit <options> <container name> <image>:<tag> 명령어로 사용
docker commit 명령어 사용 옵션
-a 옵션 → 만든이
-m 옵션 → log 메시지
변경된 컨테이너 이미지 생성 예시
# 변경된 내용을 가지는 이미지 생성
$ docker commit -a "hippo" -m "add /bin/ip" df8b nginx:ip
sha256:96ec98bcb7ac7344d8c36a01601f3ffb202f50a5bfcca6cae21c7624abfc5b64
# 생성된 이미지 확인
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
test vol b00a026e35cd 51 minutes ago 133MB
locahost:5000/vol v1 b00a026e35cd 51 minutes ago 133MB
localhost:5000/vol v1 b00a026e35cd 51 minutes ago 133MB
test user 0e7f2d0690f8 2 hours ago 73.1MB
ubuntu latest 1318b700e415 5 hours ago 72.8MB
forestian/test web d19fbcd7480b 18 hours ago 133MB
nginx latest 08b152afcfae 4 days ago 133MB
registry latest 1fd8e1b0bb7e 3 months ago 26.2MB
# 생성된 이미지를 컨테이너 실행
$ docker run -d -it --name webip nginx:ip
2b2f20c81ea677e33e3cda36e6ef8ad21e2dd95dbc69a5b91dcbe6ba9a6851ad
# 실행중인 컨테이너 확인
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2b2f20c81ea6 nginx:ip "/docker-entrypoint.…" 27 seconds ago Up 26 seconds 80/tcp webip
# 추가된 부분에 대한 테스트로 정상적으로 이미지 생성 확인
$ docker exec webip ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
14: eth0@if15: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:04 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.17.0.4/16 brd 172.17.255.255 scope global eth0
valid_lft forever preferred_lft forever
4. 컨테이너 상세 정보 조회 → docker inspect <컨테이너 이름>
docker inspect <container name> 명령어로 사용
# 실행중인 컨테이너 확인
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2b2f20c81ea6 nginx:ip "/docker-entrypoint.…" 2 minutes ago Up 2 minutes 80/tcp webip
# 컨테이너의 자세한 내용 조회
$ docker inspect 2b2 | less
[
{
"Id": "2b2f20c81ea677e33e3cda36e6ef8ad21e2dd95dbc69a5b91dcbe6ba9a6851ad",
"Created": "2021-07-27T02:31:18.37452262Z",
"Path": "/docker-entrypoint.sh",
"Args": [
"/bin/bash"
],
<...중략...>
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04",
"DriverOpts": null
}
}
}
}
]
5. 네트워크 상세 정보 조회 → docker network inspect <네트워크 이름>
# 이미지 리스트 확인
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
test vol b00a026e35cd 51 minutes ago 133MB
locahost:5000/vol v1 b00a026e35cd 51 minutes ago 133MB
localhost:5000/vol v1 b00a026e35cd 51 minutes ago 133MB
test user 0e7f2d0690f8 2 hours ago 73.1MB
ubuntu latest 1318b700e415 5 hours ago 72.8MB
forestian/test web d19fbcd7480b 18 hours ago 133MB
nginx latest 08b152afcfae 4 days ago 133MB
registry latest 1fd8e1b0bb7e 3 months ago 26.2MB
# nginx:ip 이름을 가진 이미지의 상세 정보 확인
$ docker image inspect nginx:ip
[
{
"Id": "sha256:96ec98bcb7ac7344d8c36a01601f3ffb202f50a5bfcca6cae21c7624abfc5b64",
"RepoTags": [
"nginx:ip"
],
"RepoDigests": [],
"Parent": "sha256:b00a026e35cdc01c6ea323dc364d0f091897afb9acb70e8404804dfdfeed98a9",
"Comment": "add /bin/ip",
<...중략...>
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:814bff7343242acfd20a2c841e041dd57c50f0cf844d4abd2329f78b992197f4",
"sha256:7c0b223167b96d7deaacf1e1d2d35892166645b09b17bcc8675a4d882ef84893",
"sha256:59b01b87c9e7f668b740d23eb872c5964636c33aef795f1186f08b172197bc35",
"sha256:988d9a3509bbb7ea8037d4eba3a5e0ada5dc165144c8ff0df89c0048d1ac6132",
"sha256:b857347059916922b353147882544f17bb96e64c639081c0677bf386c446be4f",
"sha256:e3135447ca3e69c6975aee1621c406e3865e0e143c807bbdcf05abefa56054a2",
"sha256:cbf5cd72e52c438d7b56ef2e4ecec55c7086194447ee3e841c1f0f3cf2d1d57a"
]
},
"Metadata": {
"LastTagTime": "2021-07-27T11:27:55.465105417+09:00"
}
}
]
7. 볼륨 상세 정보 조회 → docker volume inspect <볼륨 이름>
docker volume inspect <volume name> 명령어로 사용
docker volume create disk → 볼륨 생성
docker volume ls 명령어로 볼륨 확인 가능
# disk1 이름을 가진 volume 생성
$ docker volume create disk1
disk1
# 생성된 volume 확인
$ docker volume ls
DRIVER VOLUME NAME
local 6a78c5df00f787b72e00cc634b8f79ac7679ac1d60985618f59ec8d3cbf96cae
local 25b16fde993167ac0e3457c7492cbde6e4c0c2cecce9292db248586b2b0c3f55
local disk1
local e343d977a0e3802e449a20f60f8f9502af45f1324b220cbb33bafea06fa65918
# disk1 이름을 가진 volume의 자센한 내용 확인
$ docker volume inspect disk1
[
{
"CreatedAt": "2021-07-27T13:08:35+09:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/disk1/_data",
"Name": "disk1",
"Options": {},
"Scope": "local"
}
]
8. 실시간 events 출력
docke events 명령어로 사용
9. container의 로그 확인
docke logs <container name> 명령어로 사용
--since 옵션을 주면 해당 일 이후 로그 출력
실시간 events 출력
10. container의 filesystem을 tar로 저장
docker export <container name> <tar file> 명령어로 사용
11. 이미지를 tar파일 형태로 백업 저장 → docker save image > xxx.tar
docke save <image name> > xxx.tar 명령어로 사용
12. 기존 이미지 name으로 restore
docke load < xxx.tar 명령어로 사용
13. container의 프로세스 모니터링
docker top <contianer name> <option> 명령어로 사용
14. container 단위로 사용량 확인
docker status 명령어로 사용
# 전체 컨테이너의 사용량 확인
$ docker status
# 특정 컨터이너의 사용량 확인 -> 컨테이너 확인
$ docker ps
$ docker status
15. volume 사용량 확인
docker system df 명령어로 사용
$ docker system df
16. docker system prune <option> 명령어 사용
docker system prune → stop 되어있는 container를 제거
docker system prune -a → 컨테이너에서 사용하고 있지 않는 이미지를 모두 제거
$ docker system prune
$ docker system df
$ docker system prune -a
$ docker system df