Cette page est affichée en anglais. Une traduction française est en cours.
SkillsApr 12, 2026·2 min de lecture

k6 — Modern Load Testing Tool Using Go and JavaScript

k6 is a modern load testing tool built by Grafana Labs. Write test scripts in JavaScript, run them in a high-performance Go runtime. Developer-centric with CLI-first workflow, CI/CD integration, and Grafana Cloud for result analysis.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
step-1.md
Commande d'installation directe
npx -y tokrepo@latest install 4240522f-364b-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

TL;DR
k6 lets you write load tests in JavaScript and run them in a high-performance Go runtime.
§01

What it is

k6 is a modern load testing tool built by Grafana Labs. You write test scripts in JavaScript (ES6), and k6 executes them in a high-performance Go runtime (not Node.js). It is CLI-first, developer-friendly, and built for CI/CD integration.

k6 targets developers and QA engineers who need to validate API performance, test for regressions, and simulate concurrent user load. It works locally, in CI pipelines, and with Grafana Cloud for distributed testing and result analysis.

§02

How it saves time or tokens

k6 combines the familiarity of JavaScript with the performance of Go. Unlike JMeter or Gatling, there is no GUI to configure. Tests are code, which means they are version-controlled, reviewed in PRs, and run in CI/CD automatically. Built-in thresholds fail the test if performance SLOs are not met, catching regressions before deployment. The CLI-first workflow means load tests run alongside unit tests in the same pipeline.

§03

How to use

  1. Install k6:
brew install k6              # macOS
sudo apt install k6          # Debian/Ubuntu
  1. Write a load test script:
import http from 'k6/http';
import { check, sleep } from 'k6';

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

export default function () {
  const res = http.get('https://api.example.com/health');
  check(res, {
    'status is 200': (r) => r.status === 200,
  });
  sleep(1);
}
  1. Run the test:
k6 run load-test.js
k6 run --vus 100 --duration 2m load-test.js
§04

Example

A CI/CD-ready load test with multiple scenarios:

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

export const options = {
  scenarios: {
    smoke: {
      executor: 'constant-vus',
      vus: 1,
      duration: '10s',
    },
    load: {
      executor: 'ramping-vus',
      startVUs: 0,
      stages: [
        { duration: '1m', target: 100 },
        { duration: '3m', target: 100 },
        { duration: '1m', target: 0 },
      ],
      startTime: '15s',
    },
  },
  thresholds: {
    http_req_duration: ['p(99)<1000'],
    http_req_failed: ['rate<0.005'],
  },
};
§05

Related on TokRepo

  • Testing tools — More testing and quality assurance tools on TokRepo.
  • DevOps tools — Browse CI/CD and infrastructure tools.
§06

Common pitfalls

  • Running k6 from a single machine limits the maximum number of virtual users. For large-scale tests, use k6 Cloud or distribute across multiple machines.
  • Not setting thresholds means tests always pass regardless of performance. Define SLO-based thresholds for every test.
  • Testing against production without rate limiting can cause outages. Use staging environments or set conservative VU limits for production tests.

Questions fréquentes

Why does k6 use JavaScript but not Node.js?+

k6 embeds a Go-based JavaScript runtime (goja) that is optimized for running many virtual users concurrently with minimal memory overhead. Node.js is single-threaded and not designed for simulating thousands of concurrent connections efficiently.

Can k6 test WebSocket and gRPC endpoints?+

Yes. k6 supports HTTP/1.1, HTTP/2, WebSocket, and gRPC protocols. Extensions via the xk6 framework add support for additional protocols like Kafka, SQL, and Redis.

How does k6 integrate with Grafana?+

k6 outputs metrics to Grafana Cloud for real-time dashboards and historical analysis. You can also pipe k6 output to InfluxDB, Prometheus, or Datadog for self-hosted monitoring.

What are k6 scenarios?+

Scenarios let you define multiple workload patterns in a single test. Each scenario has its own executor (constant VUs, ramping VUs, constant arrival rate), duration, and start time. This enables smoke, load, and stress tests in one script.

Is k6 free to use?+

Yes. k6 is open source under AGPL 3.0. The CLI and all core features are free. Grafana Cloud k6 (distributed testing and cloud dashboards) is a paid service with a free tier.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires