Your K6 Tests Are Lying to You (And It’s Not K6’s Fault)

· 4 min read · Johnathan Alexander

A little over 3 years ago, I decided to give k6 a try. It was different from the load testing tools I’d used before. It’s lightweight, fast, and the metrics were impressively detailed. http_req_duration, http_req_blocked, http_req_waiting I finally felt like I actually understood what was happening inside my test runs.

Or so I thought.

K6 out of the box is excellent, but it has default behaviors that will quietly mislead you if you’re not paying attention. The biggest one? The VU model. K6 makes it cheap to spin up thousands of VUs. That’s a feature, but it removes the friction that would normally make you stop and think. In most frameworks, think-times and thread management force you to reason about what a “user” actually means. K6 skips that conversation.

Here’s what the VU model actually does: a VU is a worker that executes your entire script top to bottom, then immediately loops. The number of active VUs is actually a ceiling on concurrency, not a count of simulated users. And that distinction matters more than most people realize.

100 VUs running a 100ms script ≠ 100 VUs running a 5-second script.

VU count is meaningless without knowing iteration duration. What you intended as a concurrency test can silently become a stress test and every decision you make after that point is built on a misread of your own data.

So this probably leaves you with two questions. How do I calculate the VUs I need for my test and how do I build tests that reflect user behavior?

The VU Math Nobody Explains

It is very understandable to read 100 VUs as 100 concurrent users. I mean, at first glance the language seems pretty clear. A virtual user in K6 is a script runner. It executes your script, completes an iteration, and immediately starts another. The effective request rate your test generates depends on two things: how many VUs you have, and how long each iteration takes. This means we need to be very intentional with how we decide to build our tests.

When writing a K6 test, you must shift your mental model about how to write tests. Writing good tests in K6 requires you to have a good understanding about user behavior and firm throughput targets.

A few of good formulas to have on hand are: Total Time per Iteration = Average Response Time + Think Time Number of VUs = Throughput (Requests per Second) x Total Time per Iteration Throughput (Requests per Second) ≈ Number of VUs / Total Time per Iteration (in seconds)

VUs Aren’t Users

Users do not behave like bots, A real user is almost never actively making a request. They’re reading. Deciding. Getting distracted. Most of their session time is idle from the server’s perspective. So when you say “100 concurrent users” you mean: 100 people are on my site at the same time. But at any given millisecond, maybe only 5-10 of them are mid-request. The rest are think-timing.

A easy way to simulate user behavior is to add a sleep timer to your script.

Let’s use the following scenario, you want to simulate 10 users hitting your endpoint over the course of 30 seconds. You would probably write the following script:


javascript
import http from 'k6/http';
import { check } from 'k6';

export const options = {
  scenarios: {
    default: {
      executor: 'constant-vus',
      vus: 10,
      duration: '30s',
    },
  },
};

export default function () {
  let res = http.get('https://httpbin.org/get');
  check(res, { 'is 200': (r) => r.status === 200 });
}

Lets execute the same script but let’s add a sleep to simulate a real users behavior:


javascript
import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  scenarios: {
    default: {
      executor: 'constant-vus',
      vus: 10,
      duration: '30s',
    },
  },
};

export default function () {
  let res = http.get('https://httpbin.org/get');
  check(res, { 'is 200': (r) => r.status === 200 });
  sleep(5)
}

Between these two tests we see drastically different load.

  • Test 1: http_reqs......................: 2488 81.560681/s
  • Test 2: http_reqs......................: 60 1.865079/s

Without the sleep, you have essentially compressed a 5-minute user session to mere milliseconds. This can change the volume that you’re intending to test drastically. Instead of testing the load of 10 user, you are now testing 80x the load.

Build Tests That Tell the Truth

The sleep timer isn’t a workaround — it’s the whole point. Your load test is a model of user behavior. If the model is wrong, every number that comes out of it is wrong. It doesn’t matter how detailed your metrics are. Before you write your next test, answer three questions:

  • What does one user session actually look like? Map it out requests, pauses, decisions, everything.
  • What’s my throughput target? Real numbers from production analytics, not vibes.
  • What am I actually testing? Concurrency? Throughput? Breaking points? Each one requires a different setup.

K6 is an exceptional tool. It gives you the rope to build exactly the test you need or to hang yourself with a completely wrong one. The difference comes down to whether you modeled a user or a bot. When your test reflects reality, you can trust what it tells you. And when production surprises you anyway, at least you’ll know it wasn’t your test that lied.

$ next --step

Shipping fast and not sure what's slipping through?

Thirty minutes, no pitch deck. Tell me how your team ships and I'll tell you where I'd look first.