Stroke Example Configurations
This directory contains example configurations for different stress testing scenarios.
Basic Examples
1. Simple API Health Check
# examples/basic-health-check.yaml
target:
url: "https://api.example.com/health"
method: "GET"
timeout: 10
load:
requests: 1000
concurrency: 20
duration: "2m"
pattern: "constant"
reporting:
format: ["console", "json"]
output_dir: "./results"
2. POST API with Authentication
# examples/authenticated-post.yaml
target:
url: "https://api.example.com/api/v1/users"
method: "POST"
headers:
Content-Type: "application/json"
Authorization: "Bearer your-jwt-token-here"
body: |
{
"username": "testuser",
"email": "test@example.com",
"role": "user"
}
timeout: 30
load:
requests: 5000
concurrency: 100
duration: "5m"
pattern: "ramp"
ramp_up: "30s"
rate_limiting:
enabled: true
requests_per_second: 200
reporting:
format: ["console", "html", "json"]
output_dir: "./test-results"
percentiles: [50, 90, 95, 99]
Advanced Scenarios
3. E-commerce Checkout Simulation
# examples/ecommerce-checkout.yaml
target:
url: "https://shop.example.com/api/checkout"
method: "POST"
headers:
Content-Type: "application/json"
X-API-Key: "your-api-key"
User-Agent: "Stroke/1.0 LoadTester"
body: |
{
"items": [
{"sku": "ITEM-001", "quantity": 2, "price": 29.99},
{"sku": "ITEM-002", "quantity": 1, "price": 49.99}
],
"customer": {
"email": "loadtest@example.com",
"shipping_address": {
"street": "123 Test St",
"city": "Test City",
"country": "US"
}
},
"payment": {
"method": "card",
"token": "test_token_12345"
}
}
timeout: 60
load:
requests: 10000
concurrency: 150
duration: "10m"
pattern: "spike"
rate_limiting:
enabled: true
requests_per_second: 100
failure_injection:
enabled: true
network_delay: "50ms"
drop_rate: 0.02 # 2% packet loss
error_rate: 0.01 # 1% forced errors
reporting:
format: ["console", "html", "json", "csv"]
output_dir: "./checkout-stress-results"
percentiles: [50, 75, 90, 95, 99, 99.9]
4. High-Load Database API Test
# examples/database-api-test.yaml
target:
url: "https://api.example.com/api/v2/users/search"
method: "POST"
headers:
Content-Type: "application/json"
Authorization: "Bearer high-load-test-token"
body: |
{
"query": "active users",
"filters": {
"created_after": "2023-01-01",
"status": "active",
"limit": 100
},
"sort": "created_at desc"
}
timeout: 45
load:
requests: 50000
concurrency: 500
duration: "15m"
pattern: "ramp"
ramp_up: "2m"
rate_limiting:
enabled: true
requests_per_second: 1000
failure_injection:
enabled: true
network_delay: "25ms"
drop_rate: 0.005 # 0.5% packet loss
error_rate: 0.02 # 2% server errors
reporting:
format: ["console", "html", "json"]
output_dir: "./database-load-results"
percentiles: [50, 90, 95, 99, 99.5, 99.9]
5. Microservice Chain Test
# examples/microservice-chain.yaml
target:
url: "https://gateway.example.com/api/v1/orders/process"
method: "POST"
headers:
Content-Type: "application/json"
X-Request-ID: "stroke-test-{{.RequestID}}"
Authorization: "Bearer microservice-test-token"
body: |
{
"order_id": "ORDER-{{.Timestamp}}-{{.WorkerID}}",
"customer_id": "CUST-{{.RandomInt}}",
"items": [
{
"product_id": "PROD-{{.RandomChoice:123,456,789}}",
"quantity": {{.RandomInt:1,5}},
"price": {{.RandomFloat:10.00,99.99}}
}
],
"metadata": {
"source": "load_test",
"test_run": "{{.TestRunID}}"
}
}
timeout: 120
load:
requests: 25000
concurrency: 200
duration: "20m"
pattern: "constant"
rate_limiting:
enabled: true
requests_per_second: 300
failure_injection:
enabled: true
network_delay: "100ms"
drop_rate: 0.01 # 1% packet loss
error_rate: 0.03 # 3% server errors
reporting:
format: ["console", "html", "json", "csv"]
output_dir: "./microservice-test-results"
percentiles: [50, 75, 90, 95, 99, 99.9]
Usage Instructions
Running Examples
# Run a basic health check
stroke -config examples/basic-health-check.yaml
# Run with custom settings
stroke -config examples/authenticated-post.yaml -concurrency 50
# Override specific parameters
stroke -config examples/ecommerce-checkout.yaml -duration 3m -rps 50
Customizing Configurations
- Update URLs: Replace example URLs with your actual endpoints
- Set Authentication: Add your actual API keys, tokens, or credentials
- Adjust Load: Modify concurrency and request counts based on your needs
- Configure Outputs: Choose reporting formats and output directories
Load Patterns
- constant: Steady rate throughout the test
- ramp: Gradually increase load over ramp_up duration
- spike: Sudden bursts of high load
Rate Limiting Strategies
- Fixed Rate: Set
requests_per_second
for consistent throttling - Burst: Allow short bursts above the rate limit
- Adaptive: Automatically adjust based on response times and errors
Best Practices
- Start Small: Begin with low concurrency and gradually increase
- Monitor Resources: Watch server CPU, memory, and database connections
- Test Incrementally: Run multiple tests with increasing load
- Document Results: Save reports and analyze trends over time
- Respect Rate Limits: Don't overwhelm production systems
Safety Notes
⚠️ WARNING: These examples can generate significant load. Always:
- Test against staging/test environments first
- Get permission before testing production systems
- Monitor system resources during tests
- Have a plan to stop tests if issues arise
- Consider the impact on other users/services
Pro Tip: Use the -verbose
flag to see detailed configuration before starting the test!