K6 - MacKittipat/note-developer GitHub Wiki

Sample K6 script

import http from 'k6/http';
import { sleep } from 'k6';

export const options = {
  vus: 1,
  duration: '30s',
};

export default function () {
  http.get('https://test.k6.io');
  sleep(1);
}

Sample K6 response

          /\      |‾‾| /‾‾/   /‾‾/
     /\  /  \     |  |/  /   /  /
    /  \/    \    |     (   /   ‾‾\
   /          \   |  |\  \ |  (‾)  |
  / __________ \  |__| \__\ \_____/ .io

  execution: local
     script: .\script.js
     output: -

  scenarios: (100.00%) 1 scenario, 1 max VUs, 1m0s max duration (incl. graceful stop):
           * default: 1 looping VUs for 30s (gracefulStop: 30s)


     data_received..................: 282 kB 9.1 kB/s
     data_sent......................: 2.7 kB 87 B/s
     http_req_blocked...............: avg=22.14ms  min=0s       med=0s       max=531.46ms p(90)=0s       p(95)=0s
     http_req_connecting............: avg=10.53ms  min=0s       med=0s       max=252.8ms  p(90)=0s       p(95)=0s
     http_req_duration..............: avg=264.25ms min=253.08ms med=254.62ms max=489.19ms p(90)=254.97ms p(95)=255.56ms
       { expected_response:true }...: avg=264.25ms min=253.08ms med=254.62ms max=489.19ms p(90)=254.97ms p(95)=255.56ms
     http_req_failed................: 0.00%  ✓ 0        ✗ 24
     http_req_receiving.............: avg=265.14µs min=0s       med=0s       max=999.5µs  p(90)=758.98µs p(95)=958.54µs
     http_req_sending...............: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s
     http_req_tls_handshaking.......: avg=11.17ms  min=0s       med=0s       max=268.08ms p(90)=0s       p(95)=0s
     http_req_waiting...............: avg=263.99ms min=253.08ms med=254.22ms max=489.19ms p(90)=254.97ms p(95)=255.56ms
     http_reqs......................: 24     0.774107/s
     iteration_duration.............: avg=1.29s    min=1.25s    med=1.25s    max=2.02s    p(90)=1.26s    p(95)=1.26s
     iterations.....................: 24     0.774107/s
     vus............................: 1      min=1      max=1
     vus_max........................: 1      min=1      max=1

                                                                                                                                                    
running (0m31.0s), 0/1 VUs, 24 complete and 0 interrupted iterations                                                                                
default ✓ [======================================] 1 VUs  30s            

Response meaning

  • vus (Virtual Users) : an emulation of a user performing your script
  • iterations : Number of time the script was executed by VUs
  • iteration_duration : The time to complete one full iteration
  • http_reqs : How many total HTTP requests k6 generated.
  • http_req_duration : Total time for the request. It's equal to http_req_sending + http_req_waiting + http_req_receiving

Reference