GuideBeginner
Performance and Load Testing with k6
Learn the difference between "does it work?" and "does it hold up under load?" with performance and load testing using k6, the industry-standard tool. You'll cover the test types (smoke, load, stress, spike, soak), the anatomy of a k6 script and its VU (virtual user) model, the metrics that actually matter (p95/p99 latency, throughput/RPS, error rate — and why the average lies), load profiles with `stages`, and thresholds: limits that make a test PASS or FAIL automatically, like a performance quality gate. The case study is a Reservo API (`GET /rooms`, `POST /quote`, `POST /book`) running locally: since k6 isn't installed in this guide's environment, its scripts and output are shown as clearly labeled content verified against the official docs, while the real metrics (p95, RPS, error rate) are actually computed with a Python load generator hitting the API. It closes with a final project: a complete smoke → load → stress load test, with thresholds, business-flow checks (quote → book), and the CI pipeline.
- 64
- lessons
- 8
- modules
- English · Spanish
- available in
- Yes
- certificate
- Free
- access
Outcomes
What you'll be able to do
- Distinguish "does it work?" (functional testing) from "does it hold up?" (load testing), and recognize the test types: smoke, load, stress, spike, and soak
- Read and write the anatomy of a k6 script: the `default` function, `http.get`/`post`, `check()`, `sleep()`, and the VU (concurrent virtual user) model
- Interpret the key metrics of a load test: latency percentiles (p90/p95/p99, and why the average lies), throughput/RPS, and error rate
- Model realistic load profiles with `stages` (ramp-up, steady, ramp-down), and distinguish executors driven by VUs vs. by arrival rate
- Define thresholds (SLOs) that make a load test PASS or FAIL as a performance quality gate, and choose the right threshold
- Use `check()` and `group()` to verify response correctness under load, parametrize data, and correlate a full flow (quote → book)
- Analyze results, export metrics, spot a performance regression between runs, and run a load test in CI as a pipeline gate
- Design a complete load test for a real API: smoke → load → stress, with thresholds, business-flow checks, and the CI pipeline
Before you start
What you need to bring
It's for you if...
- Backend devs who need to know whether their API holds up under real traffic before a user in production finds out first
- Teams that want performance thresholds (SLOs) that block a deploy automatically, not just get eyeballed after the fact
- Devs who confuse "worked on my machine" with "holds up under concurrent load," and want to measure instead of guess
- Teams evaluating k6 as their load-testing tool who want to understand its model before wiring it into CI
Requirements and materials
- Basic HTTP knowledge (methods, status codes, JSON) and familiarity with a simple REST API
- Python 3.14 installed locally (the load generator uses `threading`/`concurrent.futures`/`statistics` from the standard library)
- No need to have k6 installed — the guide treats it as content; it can optionally be installed to run the real scripts
Content
The syllabus, module by module
Open any of them to see its lessons.
- 1. Module introduction: two distinct questions
- 2. Functional vs load: two distinct questions
- 3. The questions a load test answers
- 4. The types: smoke, load, stress, spike, soak
- 5. What k6 is and its runtime
- 6. The Reservo API and seeing it respond
- 7. First contact: a k6 script and a Python generator
- 8. Mini-project: your first load measurement
- 1. Module introduction: the script and the virtual user
- 2. The `default` function and the VU loop
- 3. `http.get` and `http.post` with body and headers
- 4. `check()`: verifying the response
- 5. `sleep()` and think time
- 6. `options`: `vus` and `duration`
- 7. VUs vs iterations and reading the k6 summary
- 8. Mini-project: a k6 script and its Python model
- 1. Module introduction: the test's dashboard
- 2. Latency: what it is and why percentiles, not the average
- 3. p50/p90/p95/p99 with `statistics.quantiles`
- 4. Throughput/RPS and its relationship with VUs
- 5. The error rate and why it matters
- 6. Reading the `k6 run` summary
- 7. Average vs p95 on a tailed distribution
- 8. Mini-project: measure Reservo's metrics
- 1. Module introduction: giving the load a shape
- 2. Why a constant load isn't enough
- 3. The stages: ramp-up, steady, ramp-down
- 4. The shapes: constant, ramp, and spike
- 5. The executors: constant-vus vs ramping-vus
- 6. constant-arrival-rate: load by arrival rate
- 7. Choosing the profile according to the question
- 8. Mini-project: a staged load profile
- 1. Module introduction: from measuring to judging
- 2. What a threshold is and the pass/fail
- 3. k6's thresholds: p95, error, and checks
- 4. The nonzero exit code that fails CI
- 5. SLO/SLA: choosing the threshold with judgment
- 6. The performance gate, like coverage gates
- 7. `abortOnFail` and per-scenario thresholds
- 8. Mini-project: a performance gate
- 1. Module introduction: from hitting a route to a scenario
- 2. `check()` for correctness under load
- 3. A failing check vs an aborting threshold
- 4. `group()` to organize the steps (content)
- 5. Parametrizing data: don't hit a hot route
- 6. Correlation: extract and reuse (quote → book)
- 7. Realistic think time with jitter
- 8. Mini-project: a realistic Reservo scenario
- 1. Module introduction: from measuring to analyzing and automating
- 2. Reading the summary and the trend metric
- 3. Exporting results (JSON/CSV) and why
- 4. Detecting a performance regression
- 5. Finding the bottleneck (app, DB, network)
- 6. Running k6 in CI: the `load.yml` and the gate
- 7. When to run the load test
- 8. Mini-project: export and detect a regression
- 1. Module introduction: assembling the complete test
- 2. The quote→book scenario with checks
- 3. The smoke→load→stress profile with stages
- 4. The thresholds tied to the SLO
- 5. The run and the metrics (p95/RPS/error)
- 6. The threshold gate and exporting to JSON
- 7. The CI `load.yml` as content
- 8. Project: the complete Reservo load test
Common questions
What people usually ask
No limit. It's a free guide: come in whenever you like, as often as you like.
No. Modules run from easier to harder, but you can jump to the one you need. Progress is saved per lesson.
Whatever is needed is listed under “What you need to bring”, above. If nothing is listed there, you can start from zero.
In the Club's WhatsApp group, and every two weeks there's a live with an instructor where questions get worked through.
Yes. It's issued automatically once you finish every lesson, with a verifiable code you can share on LinkedIn.
Start whenever you like
What students say
These reviews are from enrolled students who completed at least 50% of the course. We moderate reviews only on content grounds (spam, offensive language, personal data), never for being critical or negative.
No approved reviews yet.
Be the first to share your experience!