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: 为什么不用 Node.js? A: k6 的 JS 引擎是嵌入 Go 的 goja(不是 V8/Node)。这样每个 VU 开销很小,单机可以模拟几千 VU。
Q: 和 Grafana 集成? A: 输出到 Prometheus Remote Write 或 Grafana Cloud k6,然后在 Grafana 面板看实时负载测试指标。
来源与致谢 Sources
- Docs: https://grafana.com/docs/k6
- GitHub: https://github.com/grafana/k6
- License: AGPL 3.0