Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 36 ยท Patterns and Analysis

Analyzing k6 Results and Finding Bottlenecks

Turn k6 numbers into conclusions: read latency versus load curves, spot the knee and saturation, separate generator limits from server limits, find common bottlenecks and write up findings.

A finished test leaves you with graphs and numbers. The skill that separates a useful load test from a pretty one is interpretation: deciding what the system is doing, why, and what to change. This lesson gives you a method that works for any application.

Honesty note. k6 cannot run on this site. The numbers below are made-up illustrations, and the runnable blocks are Node stand-ins that analyze sample data the way you would analyze exported k6 results. None of it measures a real system.

Step 0: trust the test first

Before you blame the application, confirm the measurement is sound:

  1. Did the load generator keep up? Check dropped_iterations, the generator's CPU (keep it under about 70 to 80 %), memory and network. A saturated generator produces slow "responses" that are really its own delay.
  2. Were the errors real? Look at http_req_failed and the status codes. 429 means rate limiting, 401 means your token expired, 503 means the server (or a proxy) shed load. Each has a different cause and cure.
  3. Was the target stable? No deployments, no other tests, no cron job hogging the database during the run.
  4. Did the script do what you intended? Checks passing at 100 % while returning a login page proves nothing. Spot-check a few responses.

Step 1: read the curve, not the average

Plot latency percentiles and throughput against load (VUs or arrival rate). A healthy system shows three regions:

flowchart LR
    A["Linear region:<br/>latency flat,<br/>throughput rises with load"] --> B["Knee:<br/>latency starts to climb"]
    B --> C["Saturation:<br/>throughput flat,<br/>latency and errors rise"]

The knee is where capacity ends in practice, even though the system has not yet failed.

  • In the linear region each extra user adds throughput; latency stays near its baseline.
  • At the knee, some resource nears full utilization and requests start to queue. Latency percentiles (especially p(95) and p(99)) rise before the average does.
  • In saturation throughput stops growing (or falls) while latency and errors climb. Beyond it, more load only creates longer queues, timeouts and retries.

Your answer to "how much traffic can we handle?" is usually the load just before the knee, with a safety margin, not the load at which the server finally fell over.

Node.js Stand-in: find the knee in step-test results

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Step 2: correlate with the server

k6 only shows the client's view. To explain a knee, put server-side metrics on the same time axis: CPU, memory, garbage-collection pauses, thread-pool usage, database connections, queue lengths, disk and network I/O. A framework that helps is the USE method: for every resource check Utilization (how busy), Saturation (is there a queue waiting) and Errors.

Typical findings and the signature each leaves:

Bottleneck What you see
CPU-bound application CPU near 100 %, latency rises smoothly with load
Database connection pool too small Latency jumps at a fixed concurrency, DB CPU still low, requests waiting for a connection
Slow query or missing index Latency tied to one route, DB CPU high or rows scanned high
N+1 queries Query count per request grows with data size
Thread-pool or worker exhaustion Response time steps up, waiting grows while CPU is low
Memory pressure / GC Periodic latency spikes, memory climbing in soak tests
Lock contention Throughput flat while CPU is idle
Slow dependency (third-party API) Latency of routes that call it, 5xx or timeouts
Rate limiter or WAF A sudden wall of 429 or 403 at a fixed rate
Network or load balancer limit Bandwidth ceiling, connection resets, TLS handshake time (http_req_tls_handshaking) grows
The load generator Generator CPU at 100 %, dropped_iterations rising

Use k6's own timings to point the finger: if http_req_waiting grows, the server is slow to respond; if http_req_connecting or http_req_blocked grows, look at connection limits, DNS, or ephemeral port exhaustion; if http_req_receiving grows, bodies are large or bandwidth is limited.

Node.js Stand-in: classify a slowdown from timing components

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Step 3: change one thing and rerun

Performance work is an experiment. Change one variable (a connection-pool size, an index, a cache, an instance type), rerun the same test, and compare. Several simultaneous changes make the result unreadable. Also:

  • Repeat runs. Results vary from run to run (noisy neighbours, JIT warm-up, caches). Run three times and look at the spread before you celebrate a 5 % gain.
  • Warm up. The first minutes of a test often include cold caches and JIT compilation. Ramp up gradually and consider excluding the warm-up period from thresholds with delayAbortEval or scenario tags.
  • Compare like with like. Same data volume, same environment, same script, same duration.
Node.js Stand-in: is the improvement bigger than the noise?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Step 4: write it down

A useful report is short and answers questions people actually have:

  1. Goal and setup: what was tested, environment, build version, data size, script and test type.
  2. Workload: the model (open or closed), traffic mix, duration, peak rate.
  3. Result against the criteria: pass or fail per threshold, with the key numbers (p(95), p(99), error rate, throughput).
  4. Capacity: where the knee is and the safe operating load.
  5. Bottleneck and evidence: the graph that proves it (latency curve with CPU or connection-pool usage next to it).
  6. Recommendations and next test: what to change, and what to rerun to confirm.

Keep the raw data and the script version alongside the report so anyone can reproduce the run, and store results so you can trend them over time (see End-of-test Summary and Outputs and Grafana Cloud k6).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is the 'knee' in a load test curve?

    At the knee a resource nears saturation and queues form. It marks practical capacity, before outright failure.
  2. 2. http_req_waiting grows a lot but http_req_receiving stays flat. What does this point to?

    Waiting is time to first byte. Growth there means the server (or its dependencies) is slow to produce the response.
  3. 3. Why check generator CPU and dropped_iterations before analyzing the application?

    If the generator cannot keep up, measured slowness may be its own delay rather than the server's.
  4. 4. You changed three settings at once and p(95) improved. What is the problem?

    Change one variable at a time and rerun the same test, otherwise the cause is unknowable.

Summary

  • First validate the test (generator health, errors, stable target), then interpret.
  • Read latency and throughput against load: linear region, knee, saturation.
  • Correlate with server metrics using the USE method; k6 timing components help localize the problem.
  • Change one thing, repeat runs to see noise, and write a short evidence-based report.

Next: Project: Load Testing a REST API