Skip to content

Commit e299ab8

Browse files
committed
Add k6 README
1 parent f745cb7 commit e299ab8

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Load Testing with k6
2+
3+
[Grafana k6](https://k6.io/) is a tool that will run a load test scenario against an endpoint and once complete provide detailed stats on latency and throughput metrics.
4+
5+
## Installing
6+
7+
From the k6 directory run
8+
9+
```
10+
./k6-install.sh
11+
```
12+
13+
Once finished you will see an example of how to run the script.
14+
15+
## Script
16+
17+
From the k6 directory run (for example with v0.58.0)
18+
19+
```
20+
./k6-v0.58.0-macos-arm64/k6 run k6.mjs
21+
```
22+
23+
The current script `k6.mjs` loads a locally saved JSON payload which will then POST to the DCR `/Article` endpoint. The local payload file removes the fetching of the JSON payload from the test scenario.
24+
25+
You can of course configure this to be any payload and endpoint you wish.
26+
27+
## Testing Advice
28+
29+
Run the script 2-3 times to warm the app and instance if working from a cold start.
30+
31+
k6 can consume lots of memory, so ideally you shouldn't run it on the same compute as the app you are load testing.
32+
33+
k6 has a large API so its worth reading the docs and in particular the [overview](https://grafana.com/docs/k6/latest/).
34+
35+
## Output
36+
37+
Once complete k6 will output statistics like the following.
38+
39+
`http_req_duration` are the main stats to consider.
40+
41+
`iteration_duration` includes the time for k6 to run the script.
42+
43+
```
44+
/\ Grafana /‾‾/
45+
/\ / \ |\ __ / /
46+
/ \/ \ | |/ / / ‾‾\
47+
/ \ | ( | (‾) |
48+
/ __________ \ |_|\_\ \_____/
49+
50+
execution: local
51+
script: k6.mjs
52+
output: -
53+
54+
scenarios: (100.00%) 1 scenario, 10 max VUs, 1m30s max duration (incl. graceful stop):
55+
* default: 10 looping VUs for 1m0s (gracefulStop: 30s)
56+
57+
58+
59+
█ TOTAL RESULTS
60+
61+
checks_total.......................: 3786 62.955288/s
62+
checks_succeeded...................: 100.00% 3786 out of 3786
63+
checks_failed......................: 0.00% 0 out of 3786
64+
65+
✓ is status 200
66+
67+
HTTP
68+
http_req_duration.......................................................: avg=155.45ms min=54.91ms med=128.6ms max=2.23s p(90)=250.46ms p(95)=262.3ms
69+
{ expected_response:true }............................................: avg=155.45ms min=54.91ms med=128.6ms max=2.23s p(90)=250.46ms p(95)=262.3ms
70+
http_req_failed.........................................................: 0.00% 0 out of 3786
71+
http_reqs...............................................................: 3786 62.955288/s
72+
73+
EXECUTION
74+
iteration_duration......................................................: avg=158.65ms min=57.77ms med=131.66ms max=2.24s p(90)=253.37ms p(95)=265.44ms
75+
iterations..............................................................: 3786 62.955288/s
76+
vus.....................................................................: 10 min=10 max=10
77+
vus_max.................................................................: 10 min=10 max=10
78+
79+
NETWORK
80+
data_received...........................................................: 1.1 GB 19 MB/s
81+
data_sent...............................................................: 251 MB 4.2 MB/s
82+
83+
84+
85+
86+
running (1m00.1s), 00/10 VUs, 3786 complete and 0 interrupted iterations
87+
default ✓ [======================================] 10 VUs 1m0s
88+
```
89+
90+
## Testing in CODE
91+
92+
If testing in CODE:
93+
94+
- run the script from a detached instance
95+
- k6 may get killed by the OOM killer if an instance runs out of memory. First stop the DCR process using `systemctl stop {app-name}` where app-name is `article-rendering`, `facia-rendering` etc to free up memory. If the process is repeatedly killed, run from a larger instance type with more memory or run with a smaller number of VUs.
96+
- change the script endpoint to the loadbalancer of the stack you are interested in

0 commit comments

Comments
 (0)