RousselTMLEARNING

TP · Grafana k6: load and performance testing

Lab: First k6 test with checks and thresholds

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. 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. 2. Write the script

    Why? A minimal test: 10 VUs for 30 s on a simple route.

    Create smoke.js that calls http://httpbin/get with a check on the status.
  3. 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. 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. 5. Read the summary

    Why? Knowing how to read each line avoids hasty conclusions.

    Note down http_reqs, http_req_duration (avg, p95), iterations and checks. Why is the throughput around 10 requests per second?

Difficulty level : ●○○○○ (1/5)

My progress

  • ⏱ Estimated time : ≈ 30 min

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.

Ask a question about this lesson →

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...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!