카테고리 없음

TIL - 부하테스트

8나지 2024. 7. 19. 20:22
주제1 부하테스트
작성이유 참고하기 위해 

 

문제상황

상황 하는 방법 해당 파일이 있는 (나는 reapp.js) 곳에 프로그램 설치 후 reapp.js 실행 시켜서 로그인 함.
로그인 후에 토큰 확인하고 -> test.yaml 파일 만들고 거기다 .. 테스트 진행파일 작성에 있는 내용을 삽입 및 저장


*** 새로운 터미널을 열고 : 그렇지 않으면 중간에 꺼짐..***
artillery run test.yaml -o ./test.json 실행
 
그다음
artillery report --output ./report.html ./test.json  실행 하면
 
 DEPRECATION NOTICE 라는 이름과 함께 네모 박스에 결과 확인 가능


+ 결과확인할때 report.html 에다 결과 볼 수 있게 입력 했으므로
report.html 파일 실행하면 결과 나옴 
해결방법



   
   

 

 

 

 
# 간단한 부하 테스트
https://www.artillery.io/
## 부하테스트 프로그램 설치
```bash
npm install -g artillery
```

## 테스트 진행 파일 작성
```yaml
config:
  target: "http://localhost:3000" 
  phases:
    - duration: 20
      arrivalRate: 5
      name: "TodoService"

scenarios:
  - name: "get todo"
    flow:
      - get:
          url: "/todo-items"
          headers:
            Authorization: "여기는 내꺼 로그인한 token  eyJhbGciOqiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwibmFtZSI6IuyasOykgO2YuCIsImVtYWlsIjoibm9nZ29uZ0BleGFtcGxlLmNvbSIsInJvbGUiOiJ0dXRvciIsImlhdCI6MTcyMTIxNjAwOX0.UOsNOog71HQ2z9M53aHDuerl5GTx0ZosrSC-B-PLXpE"               
```

## 테스트 실행
-o: 결과 파일 저장
```bash
artillery run test.yaml -o ./test.json
```

## 결과 확인
```bash
artillery report --output ./report.html ./test.json
```

## 결과 지표
- http.codes.200: 상태 코드가 200(OK)인 HTTP 응답 수
- http.request_rate: 초당 HTTP 요청 수
- http.requests: 총 HTTP 요청 수
- http.response_time: 최소, 최대, 중앙값, 95번째 백분위수 및 99번째 백분위수 응답 시간을 포함한 HTTP 요청의 응답 시간에 대한 통계
- http.responses: 수신된 총 HTTP 응답 수
- vusers.completed: 테스트를 완료한 총 가상 사용자 수
- vusers.created: 테스트 중에 생성된 총 가상 사용자 수
- vusers.created_by_name: test.yaml 파일에 정의된 각 시나리오에 대해 생성된 가상 사용자 수
- vusers.failed: 테스트 중 실패한 총 가상 사용자 수
- vusers.session_length: 최소, 최대, 중앙값, 95번째 백분위수 및 99번째 백분위수 세션 길이를 포함하여 가상 사용자의 세션 길이에 대한 통계

 

처음에 나온 결과

Test run id: ta9qw_fxwcdn7za3zyd66pz8pjxb7jhaawq_phx5
Phase started: TodoService (index: 0, duration: 20s) 19:54:45(+0900)

--------------------------------------
Metrics for period to: 19:54:50(+0900) (width: 3.203s)
--------------------------------------

errors.ECONNREFUSED: ........................................................... 20
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 20
vusers.created: ................................................................ 20
vusers.created_by_name.get todo: ............................................... 20
vusers.failed: ................................................................. 20


Warning: multiple batches of metrics for period 1721386480000 2024-07-19T10:54:40.000Z
Phase completed: TodoService (index: 0, duration: 20s) 19:55:05(+0900)

--------------------------------------
Metrics for period to: 19:55:00(+0900) (width: 9.204s)
--------------------------------------

errors.ECONNREFUSED: ........................................................... 50
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 50
vusers.created: ................................................................ 50
vusers.created_by_name.get todo: ............................................... 50
vusers.failed: ................................................................. 50


Warning: multiple batches of metrics for period 1721386490000 2024-07-19T10:54:50.000Z
--------------------------------------
Metrics for period to: 19:55:10(+0900) (width: 5.203s)
--------------------------------------

errors.ECONNREFUSED: ........................................................... 30
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 30
vusers.created: ................................................................ 30
vusers.created_by_name.get todo: ............................................... 30
vusers.failed: ................................................................. 30


All VUs finished. Total time: 20 seconds

--------------------------------
Summary report @ 19:55:06(+0900)
--------------------------------

errors.ECONNREFUSED: ........................................................... 100
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 100
vusers.created: ................................................................ 100
vusers.created_by_name.get todo: ............................................... 100
vusers.failed: ................................................................. 100

 

다시 해본 결과

t2023-m0091@t2023-m0091ui-MacBookAir backend % artillery run test.yaml -o ./test.json
Test run id: tn9ar_ar77rfyr4x4m9e8y6ckzcwnpwpexa_7ztk
Phase started: TodoService (index: 0, duration: 20s) 20:04:53(+0900)

--------------------------------------
Metrics for period to: 20:05:00(+0900) (width: 5.222s)
--------------------------------------

http.codes.200: ................................................................ 30
http.downloaded_bytes: ......................................................... 26490
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 30
http.response_time:
  min: ......................................................................... 9
  max: ......................................................................... 169
  mean: ........................................................................ 26.7
  median: ...................................................................... 13.9
  p95: ......................................................................... 71.5
  p99: ......................................................................... 90.9
http.responses: ................................................................ 30
vusers.completed: .............................................................. 30
vusers.created: ................................................................ 30
vusers.created_by_name.get todo: ............................................... 30
vusers.failed: ................................................................. 0
vusers.session_length:
  min: ......................................................................... 11.7
  max: ......................................................................... 197.5
  mean: ........................................................................ 33
  median: ...................................................................... 18.7
  p95: ......................................................................... 90.9
  p99: ......................................................................... 108.9


Phase completed: TodoService (index: 0, duration: 20s) 20:05:13(+0900)

--------------------------------------
Metrics for period to: 20:05:10(+0900) (width: 9.23s)
--------------------------------------

http.codes.200: ................................................................ 50
http.downloaded_bytes: ......................................................... 44150
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 50
http.response_time:
  min: ......................................................................... 11
  max: ......................................................................... 89
  mean: ........................................................................ 18.3
  median: ...................................................................... 15
  p95: ......................................................................... 23.8
  p99: ......................................................................... 39.3
http.responses: ................................................................ 50
vusers.completed: .............................................................. 50
vusers.created: ................................................................ 50
vusers.created_by_name.get todo: ............................................... 50
vusers.failed: ................................................................. 0
vusers.session_length:
  min: ......................................................................... 13.3
  max: ......................................................................... 92
  mean: ........................................................................ 22.3
  median: ...................................................................... 18.7
  p95: ......................................................................... 28.5
  p99: ......................................................................... 40.9


--------------------------------------
Metrics for period to: 20:05:20(+0900) (width: 3.218s)
--------------------------------------

http.codes.200: ................................................................ 20
http.downloaded_bytes: ......................................................... 17660
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 20
http.response_time:
  min: ......................................................................... 10
  max: ......................................................................... 22
  mean: ........................................................................ 15.1
  median: ...................................................................... 15
  p95: ......................................................................... 21.1
  p99: ......................................................................... 21.1
http.responses: ................................................................ 20
vusers.completed: .............................................................. 20
vusers.created: ................................................................ 20
vusers.created_by_name.get todo: ............................................... 20
vusers.failed: ................................................................. 0
vusers.session_length:
  min: ......................................................................... 11.9
  max: ......................................................................... 52.5
  mean: ........................................................................ 19.8
  median: ...................................................................... 17.3
  p95: ......................................................................... 27.9
  p99: ......................................................................... 27.9


All VUs finished. Total time: 20 seconds

--------------------------------
Summary report @ 20:05:14(+0900)
--------------------------------

http.codes.200: ................................................................ 100
http.downloaded_bytes: ......................................................... 88300
http.request_rate: ............................................................. 5/sec
http.requests: ................................................................. 100
http.response_time:
  min: ......................................................................... 9
  max: ......................................................................... 169
  mean: ........................................................................ 20.2
  median: ...................................................................... 15
  p95: ......................................................................... 39.3
  p99: ......................................................................... 90.9
http.responses: ................................................................ 100
vusers.completed: .............................................................. 100
vusers.created: ................................................................ 100
vusers.created_by_name.get todo: ............................................... 100
vusers.failed: ................................................................. 0
vusers.session_length:
  min: ......................................................................... 11.7
  max: ......................................................................... 197.5
  mean: ........................................................................ 25
  median: ...................................................................... 18.4
  p95: ......................................................................... 53
  p99: ......................................................................... 108.9
Log file: ./test.json
t2023-m0091@t2023-m0091ui-MacBookAir backend % artillery report --output ./report.html ./test.json

┌───────────────────────────────────────────────────────────────────────┐
│                          DEPRECATION NOTICE                           │
├───────────────────────────────────────────────────────────────────────┤
│ The "report" command is deprecated and will be removed in a future    │
│ release of Artillery.                                                 │
│                                                                       │
│ Artillery Cloud is now the recommended way to visualize test results. │
│ It provides more comprehensive reporting, advanced visualizations,    │
│ and includes a free tier.                                             │
│                                                                       │
│ Sign up on https://app.artillery.io                                 │
└───────────────────────────────────────────────────────────────────────┘

Report generated: ./report.html

 

ㅇㅇ