import http from "k6/http";
export const options = {
scenarios: {
constant_request_rate: {
executor: 'constant-arrival-rate',
rate: 10, // 초당 10건
timeUnit: '1s', // 기준 시간 (1초)
duration: '1m', // 테스트 전체 지속 시간
preAllocatedVUs: 10, // 처음에 미리 할당할 VU 수 (10~20 추천)
maxVUs: 300, // 응답이 느려질 경우 대비한 최대 VU 수
},
},
};
export default function () {
// VU가 실행하는 코드
const url = "http://localhost:8080/api/auth";
http.get(url);
}
k6 run script.js
k6 run --vus 10 --duration 30s script.js
linux
K6_WEB_DASHBOARD=true k6 run script.js
window
k6 run --out web-dashboard script.js
/\ Grafana /‾‾/
/\ / \ |\ __ / /
/ \/ \ | |/ / / ‾‾\
/ \ | ( | (‾) |
/ __________ \ |_|\_\ \_____/
execution: local
script: script.js
web dashboard: http://127.0.0.1:5665
output: -
scenarios: (100.00%) 1 scenario, 300 max VUs, 40s max duration (incl. graceful stop):
* constant_request_rate: 1.00 iterations/s for 10s (maxVUs: 1-300, gracefulStop: 30s)
█ TOTAL RESULTS
HTTP
http_req_duration..............: avg=31.71ms min=29.92ms med=31.22ms max=34.53ms p(90)=33.73ms p(95)=34.13ms
{ expected_response:true }...: avg=31.71ms min=29.92ms med=31.22ms max=34.53ms p(90)=33.73ms p(95)=34.13ms
http_req_failed................: 0.00% 0 out of 11
http_reqs......................: 11 1.096671/s
EXECUTION
iteration_duration.............: avg=31.88ms min=29.92ms med=31.22ms max=36.37ms p(90)=33.73ms p(95)=35.05ms
iterations.....................: 11 1.096671/s
vus............................: 1 min=0 max=1
vus_max........................: 1 min=1 max=1
NETWORK
data_received..................: 5.7 kB 573 B/s
data_sent......................: 2.0 kB 204 B/s
running (10.0s), 000/001 VUs, 11 complete and 0 interrupted iterations
constant_request_rate ✓ [======================================] 000/001 VUs 10s 1.00 iters/s
k6 run --out json=result.json script.js