Before you start
Make sure you have:- Cloned the Blnk repository to your local machine
- Docker and Docker Compose installed, for running the Blnk server
- k6 installed on your machine. Visit k6.io for installation instructions
- Your Blnk server running and accessible
If you haven’t deployed Blnk yet, follow the installation guide first.
Getting started
You can find the load test files in thetests/loadtest directory of the Blnk repository. Navigate to this directory to access all available test scripts:
Main test script
The primary load test script (script.js) supports five configurable load-testing scenarios, each controlled via environment variables.
Each scenario targets a specific aspect of your Blnk server’s transaction performance, allowing you to test different load patterns and system behaviors.
- Baseline: Steady, constant load to measure normal performance.
- Ramp: Gradually increasing load to find when your server struggles.
- Contention: Tests when one balance gets most of the traffic.
- Soak: Long-duration test (2 hours) to find memory leaks and stability issues.
- Spike: Sudden traffic surge to test recovery behavior.
SCENARIO environment variable to select which scenario to run. Each scenario has specific configuration options:
- Baseline
- Ramp
- Contention
- Soak
- Spike
Understanding test results
k6 provides comprehensive metrics for each test run. Key metrics to monitor include:- http_req_duration: Request latency (p50, p95, p99 percentiles)
- http_req_failed: Error rate (should be < 0.1%)
- http_reqs: Total requests processed
- vus: Virtual users active during the test
1
Performance thresholds
The main test script (
script.js) includes built-in performance thresholds that automatically fail tests if exceeded:- Error rate: Less than 0.1% (
http_req_failed < 0.001) - P95 latency: Less than 300ms
- P99 latency: Less than 600ms
2
Exporting results
The main test script automatically exports results to Results are automatically saved to
summary.json. Run any scenario:summary.json in the current directory.3
Analyze results with TPM tool
The test suite includes a utility script to convert k6 JSON output into transactions per minute (TPM) CSV format.First, export k6 results as JSON:Then convert to CSV:The generated CSV includes: minute timestamp, requests, transactions per minute (tpm), success ratio, p50/p95/p99 latency, and apdex score.
Path to k6 JSON output file (use
--out json=output.json when running k6)Path to output CSV file
Troubleshooting
Connection refused errors
If you see connection errors, verify:- Your Blnk server is running and accessible.
- The URL matches your server’s address and port.
- Firewall rules allow connections to the Blnk server.
High error rates
If error rates exceed thresholds:- Check Blnk server logs for errors.
- Verify database connection pool settings.
- Review server resource usage (CPU, memory).
- Consider reducing virtual users or request rate.