This repository contains a modular performance testing framework built with Grafana k6. It is designed to evaluate system stability, scalability, and reliability by simulating various traffic patterns.
The project is modularized to separate testing logic from execution configurations:
/k6-performance-tests
├── /scenarios # Test configurations for different load types
│ ├── load_test.js # Normal expected load
│ ├── stress_test.js # Testing system limits
│ ├── spike_test.js # Sudden traffic bursts
│ └── soak_test.js # Long-duration reliability
├── /config # Global thresholds and environment setups
└── request_logic.js # Shared user flows and API business logic
| Test Type | Description | Goal |
|---|---|---|
| Load Test | Simulates a constant number of concurrent users | Verify if the system meets SLAs |
| Stress Test | Increases load until the system reaches its breaking point | Identify maximum capacity and recovery behavior |
| Spike Test | Sudden, extreme surge in users for a very short duration | Ensure the system doesn't crash during flash sales/events |
| Soak Test | Constant load maintained for several hours/days | Detect memory leaks and resource exhaustion |
- k6 installed: Download k6
- Node.js (Optional, for linting or managing dependencies)
To execute a specific test, run the following command from the root directory:
# Run a Load Test
k6 run scenarios/load_test.js
# Run a Stress Test
k6 run scenarios/stress_test.jsEvery test script is equipped with Thresholds to automatically determine success or failure:
- Success Rate: Over 99% of requests must return a 200 OK status.
- Latency: 95% of requests (p95) must be completed within 500ms.
To visualize results in real-time, you can output the metrics to various backends:
- InfluxDB + Grafana
k6 run --out influxdb=http://localhost:8086/k6 scenarios/load_test.js- JSON Output
k6 run --out json=reports/results.json scenarios/load_test.js