Skip to content
Skills Library
DevOps & cloud · Testing

k6

/k6

Expert k6 load and performance testing assistance covering virtual users, thresholds, metrics, and scenario scripting. Use when benchmarking APIs, performing stress testing, or integrating load tests into CI/CD.

Licence
MIT
Last repository change
01.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
5
Deprecation

No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert k6 load and performance testing assistance covering virtual users, thresholds, metrics, and scenario scripting. Use when benchmarking APIs, performing stress testing, or integrating load tests into CI/CD.

Original author description

Expert k6 load and performance testing assistance covering virtual users, thresholds, metrics, and scenario scripting. Use when benchmarking APIs, performing stress testing, or integrating load tests into CI/CD.

How it works

  1. When to Use
  2. Quick Start
  3. Core Concepts
  4. Common Patterns
  5. Best Practices
  6. Troubleshooting
  7. References
Original SKILL.md headings · 170 lines, 719 words
SKILL.md preview
---
name: k6
description: Expert k6 load and performance testing assistance covering virtual users, thresholds, metrics, and scenario scripting. Use when benchmarking APIs, performing stress testing, or integrating load tests into CI/CD.
---

# k6

k6 is a developer-centric, open-source load testing tool suitable for testing APIs, microservices, and websites. It is written in Go but you script tests in JavaScript.

## When to Use

- **Developer-Centric Load Testing**: Writing high-performance load tests in modern JavaScript / TypeScript with CLI execution.
- **CI/CD Performance Regression Gates**: Defining thresholds (`http_req_duration: ['p(95)<200']`) that automatically fail build pipelines on regressions.
- **Spike, Stress & Soak Testing**: Simulating traffic surges, system breaking points, and prolonged sustained load over hours.
- **Cloud Distributed Load Generation**: Running distributed tests across global regions via Grafana Cloud k6.

## Quick Start

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

export const options = {
  vus: 10,
  duration: "30s",
};

export default function () {
  const res = http.get("http://test.k6.io");
  check(res, {
    "status was 200": (r) => r.status == 200,
  });
  sleep(1);
}
```

Run with `k6 run script.js`.

## Core Concepts

### Go-Powered Virtual Users (VUs) with JS Runtimes

Tests are written in JavaScript, but executed by a multi-threaded Go engine with zero NodeJS overhead:

```javascript
// load-test.js
import http from "k6/http";
import { check, sleep } from "k6";

export const options = {
  stages: [
    { duration: "30s", target: 50 }, // Ramp up to 50 users
    { duration: "1m", target: 50 }, // Stay at 50 users
    { duration: "20s", target: 0 }, // Ramp down
  ],
  thresholds: {
    http_req_duration: ["p(95)<300"], // 95% of requests must complete below 300ms
    http_req_failed: ["rate<0.01"], // Error rate must be less than 1%
  },
};

export default function () {
  const res = http.get("https://api.staging.example.com/v1/items");
  check(res, {
    "status is 200": (r) => r.status === 200,
    "transaction time OK": (r) => r.timings.duration < 300,
  });
  sleep(1);
}
```

### Custom Metrics (Counters, Gauges, Trends)

Tracks domain-specific operational metrics alongside standard HTTP timings:

```javascript
import { Trend, Counter } from "k6/metrics";

const checkoutLatency = new Trend("checkout_duration");
const completedOrders = new Counter("successful_checkouts");

export default function () {
  const start = Date.now();
  const res = http.post(
    "https://api.example.com/checkout",
    JSON.stringify({ cartId: 415 }),
    {
      headers: { "Content-Type": "application/json" },
    },
  );

  if (res.status === 201) {
    completedOrders.add(1);
    checkoutLatency.add(Date.now() - start);
  }
}
```

### Tagging & Scenarios

Isolates different user behaviors (e.g. 80% readers, 20% writers) in a single test run:

```javascript
export const options = {
  scenarios: {
    readers: {
      executor: "constant-vus",
      vus: 100,
      duration: "5m",
      exec: "browseCatalog",
    },
  },
};
```

## Common Patterns

### Staged Load Test with Strict SLA Thresholds

**Problem**: Performance regressions slip into production when build pipelines lack automated latency gatechecks.

**Solution**:
Define ramp-up stages and SLO thresholds in k6 script options:

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

export const options = {
  stages: [
    { duration: "30s", target: 50 },
    { duration: "1m", target: 50 },
    { duration: "20s", target: 0 },
  ],
  thresholds: {
    http_req_duration: ["p(95)<300"],
    http_req_failed: ["rate<0.01"],
  },
};

export default function () {
  const res = http.get("https://test-api.k6.io/public/crocodiles/");
  check(res, { "status is 200": (r) => r.status === 200 });
  sleep(1);
}
```

## Best Practices

**Do**:

- Always Define Explicit `thresholds`: Let CI/CD pipelines fail automatically if latency percentiles or error rates degrade.
- Ramp Virtual Users Incrementally: Avoid instant spikes unless specifically conducting a spike/break test.
- Parameterize Test Data: Feed unique data using `SharedArray` from JSON/CSV files to prevent caching artifacts.
- Export Metrics to Prometheus / InfluxDB: Use `k6 run --out statsd` or Grafana Cloud k6 for real-time visualization.

**Don't**:

- Import heavy NPM packages directly: Use k6-compatible polyfills; k6 does not run inside standard Node.js.
- Print logs inside default test functions: `console.log()` inside virtual user loops degrades test runner performance.
- Omit think time (`sleep`): Zero sleep simulations hammer servers unrealistically and skew load profiles.

## Troubleshooting

| Error                                             | Cause                                                             | Solution                                                                  |
| :------------------------------------------------ | :---------------------------------------------------------------- | :------------------------------------------------------------------------ |
| `dial tcp: lookup ...: no such host`              | DNS resolution failure or target URL incorrect.                   | Verify endpoint connectivity and ensure VPN or internal DNS is reachable. |
| `Threshold failed: p(95)<300 [current: 450ms]`    | Target service latency exceeded predefined performance threshold. | Profile database query latency, server CPU/memory, and caching layers.    |
| `warn: Request Failed: context deadline exceeded` | Target server timing out under load.                              | Increase request timeout in k6 or scale upstream application workers.     |

## References

- [k6 Documentation](https://k6.io/docs/)

Versions

RepositoryScoreLicence
This page · G1Joshi/Agent-Skills100MIT
TerminalSkills/skills100Apache-2.0
grafana/skills100Apache-2.0
Vinay7766/omni-orchestrator100Apache-2.0
tuannv14/claude-team-toolkit100MIT
aks-builds/quality-skills100MIT

Database snapshot: 13.11.2026 · package version 638ce6e0dd0a (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100gatling
    Expert Gatling load testing assistance covering virtual users, scenarios, assertions, and throughput benchmarking. Use when designing performance tests, stress-testing HTTP APIs, or analyzing latency distributions.
  • 100running-performance-tests
    Execute load testing, stress testing, and performance benchmarking. Use when performing specialized testing. Trigger with phrases like "run load tests", "test performance", or "benchmark the system".
  • 100running-performance-tests
    Execute load testing, stress testing, and performance benchmarking. Use when performing specialized testing. Trigger with phrases like "run load tests", "test performance", or "benchmark the system".
  • 100performance-testing
    Profiles application performance under load using k6, Artillery, or JMeter to measure latency, throughput, and error rates. Use when planning load tests, stress tests, soak tests, benchmarking APIs, or identifying performance bottlenecks.
  • 90performance-testing
    Use when load-testing or benchmarking an API with concurrent virtual users and latency or error thresholds. Reuses a collection to probe a chosen failure mode and distinguishes target limits from load-generator limits. Use for requests such as "load test this API".
  • 95performance-testing
    Use for load, stress, and scalability testing of applications and APIs. Covers k6 (Grafana), JMeter, Gatling, Artillery, and Lighthouse for web performance audits. Includes test type definitions, key metrics, thresholds, CI integration patterns, and performance budgets. USE FOR:…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.