# 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. ## Install Save as a script file and run: ## Quick Use ```bash brew install k6 # macOS sudo apt install k6 # Debian/Ubuntu docker run --rm -i grafana/k6 run - < script.js ``` ```js // 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 VUs { duration: "1m", target: 50 }, // Stay at 50 { duration: "10s", target: 0 }, // Ramp down ], thresholds: { http_req_duration: ["p(95)<500"], // 95th percentile < 500ms http_req_failed: ["rate<0.01"], // Error rate < 1% }, }; export default function () { const res = http.get("https://api.tokrepo.com/assets"); check(res, { "status is 200": (r) => r.status === 200, "body has assets": (r) => r.json().length > 0, }); sleep(1); } ``` ```bash k6 run load-test.js k6 run --vus 100 --duration 2m load-test.js ``` ## Intro k6 is a modern load testing tool built by Grafana Labs. Write test scripts in JavaScript (ES6), execute them in a high-performance Go runtime (not Node.js). CLI-first, developer-friendly, with built-in metrics, thresholds, and CI/CD integration. - **Repo**: https://github.com/grafana/k6 - **Stars**: 30K+ - **Language**: Go - **License**: AGPL 3.0 ## What k6 Does - **JavaScript scripting** — ES6 modules for test logic - **Go runtime** — high performance, low overhead - **Virtual Users** — simulate concurrent users - **Scenarios** — constant, ramping, arrival-rate - **Thresholds** — pass/fail criteria for CI - **Checks** — response assertions - **Metrics** — request duration, throughput, errors - **Protocols** — HTTP, WebSocket, gRPC, Redis - **Extensions** — xk6 for custom protocols - **Output** — JSON, CSV, Grafana Cloud, Prometheus, InfluxDB ## Comparison | Tool | Scripts | Runtime | Distributed | |---|---|---|---| | k6 | JavaScript | Go | k6-operator | | Locust | Python | Python | Built-in | | JMeter | XML/GUI | Java | Built-in | | Gatling | Scala | JVM | Paid | | Artillery | YAML/JS | Node.js | Paid | ## FAQ **Q: Why not Node.js?** A: k6's JS engine is goja, embedded in Go (not V8/Node). This keeps per-VU overhead small, letting a single machine simulate thousands of VUs. **Q: Grafana integration?** A: Output to Prometheus Remote Write or Grafana Cloud k6, then view real-time load-testing metrics in a Grafana dashboard. ## Sources - Docs: https://grafana.com/docs/k6 - GitHub: https://github.com/grafana/k6 - License: AGPL 3.0 --- Source: https://tokrepo.com/en/workflows/4240522f-364b-11f1-9bc6-00163e2b0d79 Author: Script Depot