testing-performance
Perf: k6 load/stress/spike, Locust Python, JMeter, load profiles, SLA, p50/p95/p99, flame graphs
What this skill does
# testing-performance
## Purpose
This skill enables performance testing using tools like k6, Locust, and JMeter to simulate load, stress, and spike scenarios, measure metrics such as p50/p95/p99 latency, enforce SLAs, and generate flame graphs for bottleneck analysis.
## When to Use
Use this skill when assessing application performance under load, identifying scalability issues, validating SLAs, or optimizing code before production. Apply it in pre-release testing, CI/CD pipelines, or when debugging high-latency problems in web services or APIs.
## Key Capabilities
- Run load tests with k6 using VU (virtual users) and duration settings to simulate traffic.
- Generate reports with metrics like p50 (median), p95 (95th percentile), and p99 latency from test outputs.
- Define load profiles in Locust via Python scripts for custom user behaviors and ramp-up rates.
- Enforce SLAs by setting thresholds in JMeter and checking against results.
- Create flame graphs using integrated profiling in k6 or external tools to visualize CPU/memory usage.
- Support distributed testing across multiple machines for large-scale simulations.
## Usage Patterns
To perform a basic load test, select a tool based on scenario: use k6 for quick scripts, Locust for Python-based customization, or JMeter for complex scenarios with UI elements. Always define a test script first, then run with specified profiles. For CI/CD, integrate as a step that triggers on code changes. Include parameterization for environments (e.g., staging vs. production) and always analyze results post-run. Example: Script a k6 test for an API endpoint, then scale it with Locust for user simulation.
## Common Commands/API
For k6, run tests via CLI: `k6 run -u 50 -d 1m script.js` (sets 50 virtual users for 1 minute). Use thresholds like `--threshold p(95)<500` to enforce p95 latency under 500ms. Script example:
```javascript
import http from 'k6/http';
export default function() { http.get('https://api.example.com'); }
```
For Locust, start with: `locust -f locustfile.py --host https://api.example.com --users 100 --spawn-rate 10` (100 users, 10 per second). Locustfile snippet:
```python
from locust import HttpUser, task
class QuickUser(HttpUser):
@task
def endpoint(self): self.client.get("/health")
```
For JMeter, execute via: `jmeter -n -t test_plan.jmx -l results.jtl` (non-GUI mode). JMeter config in .jmx XML format includes elements like Thread Group with 50 loops and HTTP Samplers. API endpoints: If testing requires auth, set env vars like `$K6_API_KEY` in scripts (e.g., `export K6_API_KEY=your_key` before running).
## Integration Notes
Integrate this skill into workflows by wrapping commands in scripts or CI tools like GitHub Actions: e.g., `run: k6 run script.js` in a YAML step. For cloud services, pass auth via env vars (e.g., `$LOCUST_API_TOKEN`) to access protected endpoints. Combine with monitoring tools by piping outputs (e.g., k6 JSON results to Prometheus). Ensure tools are installed via package managers (e.g., `npm install -g k6` or `pip install locust`), and use Docker images for consistency (e.g., `docker run loadimpact/k6 run - < script.js`). If using APIs, endpoints like k6's cloud API require `$K6_CLOUD_TOKEN` for uploads.
## Error Handling
Check exit codes after runs: k6 returns non-zero for failures, e.g., threshold breaches. In scripts, wrap commands with try-catch for Locust (e.g., in Python: `try: run_locust() except Exception as e: log(e)`). For JMeter, parse .jtl logs for errors like "Assertion failure" and set up listeners to halt on thresholds. Common issues: Handle network errors by adding retries in scripts (e.g., k6: `http.get(url, { retries: 3 })`), and use verbose flags like `k6 run --verbose script.js` for debugging. If auth fails, verify env vars (e.g., echo `$K6_API_KEY` before execution).
## Concrete Usage Examples
1. To test an e-commerce API for 100 users over 5 minutes with k6: Write a script with a GET request, then run `k6 run -u 100 -d 5m script.js --threshold "http_req_duration{type:200} < 500"`. Analyze output for p95 latency and ensure SLA compliance.
2. For simulating user logins with Locust: Create a locustfile.py with tasks for login and browsing, then execute `locust -f locustfile.py --host https://app.example.com --users 200 --run-time 10m`. Monitor for errors and generate reports to identify bottlenecks.
## Graph Relationships
- Related to: testing (cluster), performance-test (tag), k6 (tag), locust (tag), load-test (tag)
- Connected via: testing cluster for other testing skills, e.g., unit-testing or integration-testing
- Dependencies: monitoring skills for metric analysis, deployment skills for environment setup
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.