Load testing essencial para APIs. Artillery e k6 são os melhores. Entenda diferenças e escolha o ideal.
Conceitos Principais
Artillery
Config YAML. Scenarios com phases. Plugins para métricas. Easy onboarding.
k6
Scripts JavaScript. Programático. Grafana integration. Performance superior.
Virtual Users
Simula concurrent users. Cada VU executa scenario. Rampa up/down.
Métricas
Request rate, response time (p95, p99), error rate. Custom metrics.
Passo a Passo
- Artillery Setup: npm install -g artillery. artillery.yml: config phases, scenarios. artillery run artillery.yml.
- k6 Setup: brew install k6. script.js: import http from "k6/http"; export default function() { http.get("..."); }. k6 run script.js.
- Ramp Test: Artillery: phases [{ duration: 60, arrivalRate: 10 }, { duration: 120, arrivalRate: 50 }]. k6: stages [{ duration: "1m", target: 50 }].
- Métricas Custom: Artillery: plugins. k6: Trend, Counter, Gauge. Track business metrics.
- CI Integration: Artillery: artillery run --output report.json. k6: k6 run --out cloud. Dashboard automático.
Boas Praticas
Recomendacoes
• Artillery: simple scenarios, YAML preference
• k6: complex logic, programmatic
• Rampa gradual (não 0 → 1000 instant)
• Monitor server resources
• Set SLA thresholds
Erros Comuns
Evite estes erros
• Load test em produção
• Não simular think time
• Ignorar warm-up phase
• Stress test sem monitoring
• Não definir exit criteria
Checklist
- Tool escolhido (Artillery ou k6)
- Test scenarios definidos
- Load test executado
- Métricas analisadas
- Gargalos identificados
- CI integration configurada