Load Testing
Overview
K6 is a product by Grafana which allows scripted simultaneous requests from multiple 'virtual users', in order to simulate real traffic and test the load capabilities of a service.
K6 also works for simulating traffic for the Grafana dashboard.
Load Test Configurations
Simulation script is specified like so,
export const options = {
stages: [
{ duration: '5s', target: 20 }, // traffic ramp-up from 1 to 20 users over 5 seconds.
{ duration: '3s', target: 20 }, // stay at 20 users for 30 seconds
{ duration: '5s', target: 0 }, // ramp-down to 0 users
],
};
| Stage | Duration | Virtual Users (VUs) | Description |
|---|---|---|---|
| 1 | 5s | Ramp up from 1 -> 20 | Gradually increase traffic |
| 2 | 3s | Stay at 20 | Maintain stable load |
| 3 | 5s | Ramp down to 0 | Gradually stop load |
Installing K6
https://grafana.com/docs/k6/latest/set-up/install-k6/
Running K6
The following command-line will enable a real-time dashboard on a local port specified in the console after running. While it may be useful, the K6 Web Dashboard only runs for the duration of the tests, afterwhich it turns off.
Whether the dashboard is desired or not, eithe rway the command runs the K6 testing.
K6_WEB_DASHBOARD=true k6 run script.js