What you will learn in this TP
- Write a k6 script
- Add checks and thresholds
- Interpret the summary
Introduction #
What you will learn in this section
- Write a k6 script
- Add checks and thresholds
- Interpret the summary
Context. An API is about to be exposed to a new partner. Before opening access, you check that it handles a modest load with acceptable latency.
Prerequisites: Docker · Estimated time: 30 min
Your first automatable load test.Hands-on #
Guided steps, with their solutions.
1. Start the target API
Why? httpbin provides predictable routes: normal, slow or error responses on demand.
Run httpbin in a dedicated Docker network.2. Write the script
Why? A minimal test: 10 VUs for 30 s on a simple route.
Createsmoke.jsthat callshttp://httpbin/getwith a check on the status.3. Add thresholds
Why? Thresholds turn a measurement into a verdict: the test fails if the objective is not met.
Add the thresholds: fewer than 1% failures, p95 under 200 ms. Run it again and note the exit code.4. Make the test fail
Why? Checking that a test can fail is as important as seeing it pass.
Replace the route with/delay/1(1 s response). What happens?5. Read the summary
Why? Knowing how to read each line avoids hasty conclusions.
Note downhttp_reqs,http_req_duration(avg, p95),iterationsandchecks. Why is the throughput around 10 requests per second?
Difficulty level : ●○○○○ (1/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
Load testing with Grafana k6: why, and which types of tests
Why test performance before production, the types of tests (smoke, load, stress, spike, soak, bre...
Writing k6 scripts: requests, checks, scenarios and executors
The structure of a k6 script (init, setup, default, teardown), HTTP requests, checks, groups and ...
Thresholds, metrics and results of a k6 test
Read the summary of a k6 test, understand the built-in metrics (http_req_duration, http_req_faile...
Performance testing best practices with k6
Checklist for useful load tests: objectives, realistic scenarios, environment, thresholds, observ...
Observing a k6 test: Prometheus, Grafana and correlation with the system under test
Send k6 results to Prometheus (remote write) or via OpenTelemetry, visualize them in Grafana and ...
Writing good Prometheus alerting rules (and testing them)
Design useful alerts: alert on symptoms, choose for and thresholds, severity and team labels, ann...
Website monitoring: availability, HTTPS monitoring, certificates and performance
Set up website monitoring: availability and HTTPS checks, certificate expiry, response time, Core...
k6 in continuous integration and on Kubernetes (k6-operator)
Automate performance tests: k6 in GitHub Actions and GitLab CI with blocking thresholds, distribu...
End-to-end CI/CD (4/5): deployment strategies and rollback
Deploy without downtime and without risk: recreate, rolling update, blue/green, canary, feature f...