Validates performance improvements under realistic load conditions, ensuring optimizations hold at scale and identifying bottlenecks that only appear under stress.
Validates performance improvements under realistic load conditions, running stress tests to ensure optimizations scale without breaking. Compares before/after metrics to verify bottlenecks are resolved.
/plugin marketplace add avovello/cc-plugins/plugin install optimize@cc-pluginsValidates performance improvements under realistic load conditions, ensuring optimizations hold at scale and identifying bottlenecks that only appear under stress.
✅ DOES:
❌ DOES NOT:
Best For: HTTP APIs, WebSocket, complex scenarios
# load-test.yml
config:
target: 'http://localhost:3000'
phases:
- duration: 60
arrivalRate: 10
name: "Warm up"
- duration: 120
arrivalRate: 50
name: "Sustained load"
- duration: 60
arrivalRate: 100
name: "Peak load"
scenarios:
- name: "User workflow"
flow:
- get:
url: "/api/products"
- think: 2
- post:
url: "/api/cart"
json:
product_id: 123
quantity: 1
- think: 3
- get:
url: "/api/cart"
# Run test
artillery run load-test.yml --output report.json
artillery report report.json
Best For: High load, realistic scenarios, CI/CD integration
// load-test.js
import http from 'k6/http';
import { check, sleep } from 'k6';
export let options = {
stages: [
{ duration: '1m', target: 50 }, // Ramp up
{ duration: '3m', target: 100 }, // Sustained
{ duration: '1m', target: 200 }, // Peak
{ duration: '1m', target: 0 }, // Ramp down
],
thresholds: {
http_req_duration: ['p(95)<200'], // 95% of requests < 200ms
http_req_failed: ['rate<0.01'], // Error rate < 1%
},
};
export default function() {
let response = http.get('http://localhost:3000/api/products');
check(response, {
'status is 200': (r) => r.status === 200,
'response time < 200ms': (r) => r.timings.duration < 200,
});
sleep(1);
}
k6 run load-test.js
Best For: Simple benchmarks, maximum throughput testing
# 4 threads, 200 connections, 30 seconds
wrk -t4 -c200 -d30s http://localhost:3000/api/products
# With Lua script for complex scenarios
wrk -t4 -c200 -d30s -s script.lua http://localhost:3000
Best For: Quick benchmarks
# 10,000 requests, 100 concurrent
ab -n 10000 -c 100 http://localhost:3000/api/products
Purpose: Measure current performance under normal load
config:
target: 'http://localhost:3000'
phases:
- duration: 300 # 5 minutes
arrivalRate: 50 # 50 req/s (typical load)
scenarios:
- name: "API requests"
flow:
- get:
url: "/api/users"
- get:
url: "/api/products"
- get:
url: "/api/orders"
Metrics to Capture:
Purpose: Find breaking point
phases:
- duration: 60
arrivalRate: 10
- duration: 60
arrivalRate: 50
- duration: 60
arrivalRate: 100
- duration: 60
arrivalRate: 200
- duration: 60
arrivalRate: 500 # Push until it breaks
Purpose: Test sudden traffic spike
phases:
- duration: 60
arrivalRate: 50 # Normal load
- duration: 10
arrivalRate: 500 # Sudden spike!
- duration: 60
arrivalRate: 50 # Back to normal
Purpose: Test stability over time (memory leaks, etc.)
phases:
- duration: 7200 # 2 hours
arrivalRate: 50 # Sustained load
Purpose: Test real user behavior
scenarios:
- name: "Browse and purchase"
weight: 70 # 70% of users
flow:
- get: { url: "/" }
- think: 3
- get: { url: "/api/products?category=electronics" }
- think: 5
- get: { url: "/api/products/123" }
- think: 10
- post:
url: "/api/cart"
json: { product_id: 123, quantity: 1 }
- name: "Quick search"
weight: 30 # 30% of users
flow:
- get: { url: "/api/search?q=laptop" }
- think: 2
- get: { url: "/api/products/456" }
## Load Test Plan
**Target**: Order API optimization
**Baseline**: Current performance under load
### Scenario 1: Normal Load
- **Duration**: 5 minutes
- **Arrival Rate**: 50 req/s (3,000 req/min)
- **Endpoints**: Mix of GET /orders, POST /orders, GET /products
- **Expected**: p95 < 200ms, no errors
### Scenario 2: Peak Load
- **Duration**: 5 minutes
- **Arrival Rate**: 200 req/s (12,000 req/min)
- **Endpoints**: Same mix
- **Expected**: p95 < 500ms, error rate < 1%
### Scenario 3: Stress Test
- **Duration**: 10 minutes
- **Arrival Rate**: Ramp 50 → 500 req/s
- **Purpose**: Find breaking point
# Ensure test environment mirrors production
# - Same database size/data
# - Same server specs
# - Same configuration
# Warm up application (JIT compilation, caching)
curl http://localhost:3000/api/products
curl http://localhost:3000/api/orders
curl http://localhost:3000/api/users
# Clear logs
echo "" > /var/log/app/access.log
echo "" > /var/log/app/error.log
# Run load test
artillery run load-test-baseline.yml --output baseline-results.json
# Generate report
artillery report baseline-results.json
# Capture metrics
docker stats --no-stream app > baseline-metrics.txt
# Deploy optimizations
git checkout optimized-branch
docker-compose restart app
# Wait for stabilization
sleep 30
# Run same load test
artillery run load-test-baseline.yml --output optimized-results.json
# Generate report
artillery report optimized-results.json
# Capture metrics
docker stats --no-stream app > optimized-metrics.txt
## Load Test Comparison
### Normal Load (50 req/s)
**Before Optimization**:
- p50: 145ms
- p95: 280ms
- p99: 450ms
- Throughput: 48 req/s
- Error rate: 0.2%
- CPU: 65%
- Memory: 450MB
**After Optimization**:
- p50: 35ms ✅ (76% faster)
- p95: 65ms ✅ (77% faster)
- p99: 120ms ✅ (73% faster)
- Throughput: 50 req/s ✅ (4% improvement)
- Error rate: 0.0% ✅
- CPU: 35% ✅ (46% reduction)
- Memory: 380MB ✅ (16% reduction)
### Peak Load (200 req/s)
**Before Optimization**:
- p50: 450ms
- p95: 1,250ms ⚠️
- p99: 2,800ms 🔴
- Throughput: 180 req/s (90% of target)
- Error rate: 3.5% 🔴
- CPU: 95%
- Memory: 680MB
**After Optimization**:
- p50: 85ms ✅ (81% faster)
- p95: 180ms ✅ (86% faster)
- p99: 350ms ✅ (87% faster)
- Throughput: 200 req/s ✅ (100% of target)
- Error rate: 0.1% ✅
- CPU: 55% ✅
- Memory: 420MB ✅
## Verdict
✅ **Optimizations successful under load**
✅ **Performance improvements hold at scale**
✅ **Handles peak load without errors**
✅ **Resource usage significantly reduced**
# Load Test Results
**Date**: 2025-01-15
**Test Type**: Before/After Optimization Comparison
**Target**: Order API endpoint
**Duration**: 5 minutes per test
**Load Pattern**: 50 req/s sustained
## Executive Summary
✅ **Optimization validated under load**
- **Response Time**: 76% faster (p95: 280ms → 65ms)
- **Throughput**: 4% improvement (48 → 50 req/s)
- **Error Rate**: Eliminated (0.2% → 0.0%)
- **Resource Usage**: 46% less CPU, 16% less memory
## Test Configuration
```yaml
config:
target: 'http://localhost:3000'
phases:
- duration: 300
arrivalRate: 50
scenarios:
- name: "Order operations"
flow:
- get: { url: "/api/orders" }
- think: 1
- get: { url: "/api/orders/123" }
- think: 2
- post: { url: "/api/orders", json: {...} }
| Metric | Before | After | Improvement |
|---|---|---|---|
| p50 | 145ms | 35ms | 76% faster ✅ |
| p95 | 280ms | 65ms | 77% faster ✅ |
| p99 | 450ms | 120ms | 73% faster ✅ |
| Max | 890ms | 280ms | 69% faster ✅ |
| Metric | Before | After | Improvement |
|---|---|---|---|
| Requests/sec | 48 | 50 | +4% ✅ |
| Total requests | 14,400 | 15,000 | +4% ✅ |
| Successful | 14,371 (99.8%) | 15,000 (100%) | +0.2% ✅ |
| Failed | 29 (0.2%) | 0 (0%) | -100% ✅ |
| Metric | Before | After | Improvement |
|---|---|---|---|
| CPU (avg) | 65% | 35% | -46% ✅ |
| Memory (avg) | 450MB | 380MB | -16% ✅ |
| Database connections | 45 | 15 | -67% ✅ |
Before Optimization:
Statistics for: http://localhost:3000/api/orders
Scenarios launched: 3000
Scenarios completed: 2991
Requests completed: 14400
Response time (ms):
min: 45
max: 890
median: 145
p95: 280
p99: 450
Throughput: 48 req/s
Errors:
ETIMEDOUT: 29 (0.2%)
After Optimization:
Statistics for: http://localhost:3000/api/orders
Scenarios launched: 3000
Scenarios completed: 3000
Requests completed: 15000
Response time (ms):
min: 12
max: 280
median: 35
p95: 65
p99: 120
Throughput: 50 req/s
Errors: 0 (0%)
Test: Ramp from 50 to 500 req/s over 10 minutes
Before Optimization:
After Optimization:
Before: System breaks at ~180 req/s
After: System handles 500+ req/s
Scalability Factor: 2.8× improvement (180 → 500 req/s)
✅ Ready for production deployment
Set up alerts for:
Use this agent when analyzing conversation transcripts to find behaviors worth preventing with hooks. Examples: <example>Context: User is running /hookify command without arguments user: "/hookify" assistant: "I'll analyze the conversation to find behaviors you want to prevent" <commentary>The /hookify command without arguments triggers conversation analysis to find unwanted behaviors.</commentary></example><example>Context: User wants to create hooks from recent frustrations user: "Can you look back at this conversation and help me create hooks for the mistakes you made?" assistant: "I'll use the conversation-analyzer agent to identify the issues and suggest hooks." <commentary>User explicitly asks to analyze conversation for mistakes that should be prevented.</commentary></example>