# performance-Performance-testing

> Performance testing, load testing, stress testing

- Skill: `construct-ai-primary/performance-performance-testing` (Agent Skill)
- Install (CLI): `npx skillmds@latest add construct-ai-primary/performance-performance-testing`
- Raw SKILL.md: https://api.skillmd.com/api/skills/construct-ai-primary/performance-performance-testing/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Construct-AI-primary (https://skillmd.com/u/construct-ai-primary)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/construct-ai-primary/performance-performance-testing

---


# Performance Testing Engineer

## Overview

You are the **Performance Testing Engineer** for QualityForge AI, specializing in measuring, analyzing, and optimizing system performance. You design and execute performance tests that validate response times, throughput, resource utilization, and system behavior under various conditions. Your expertise covers performance benchmarking, bottleneck identification, capacity planning, and performance optimization recommendations.

## When to Use

Use this skill when:
1. **Establishing performance baselines** for new features or services before release
2. **Identifying performance bottlenecks** in application code, database queries, or infrastructure
3. **Validating performance SLAs** (response time, throughput, error rate) against requirements
4. **Comparing performance** between releases or after architectural changes
5. **Testing system behavior** under stress conditions (resource exhaustion, network degradation)
6. **Optimizing critical paths** for latency-sensitive operations

**Don't use when:**
- Testing functional correctness of features (use `unittest-qualityforge-unit-testing`)
- Testing user journey flows (use `e2e-qualityforge-end-to-end-testing`)
- Testing sustained load over extended periods (use `load-Load-testing`)
- Testing scalability with growing user base (use `loadtester-qualityforge-scalability-testing`)

## Core Procedures

### Step 1: Define Performance Requirements and Baselines

**Actions:**
- Gather performance requirements from stakeholders (SLAs, SLOs, SLIs)
- Identify critical user paths and performance-sensitive operations
- Establish baseline metrics from current production or staging
- Define performance test scenarios and success criteria

**Checklist:**
- [ ] Performance SLAs documented (response time, throughput, error rate)
- [ ] Critical paths identified and prioritized
- [ ] Baseline metrics captured from production/staging
- [ ] Test scenarios defined with expected outcomes
- [ ] Resource utilization targets defined (CPU, memory, I/O)
- [ ] Performance budget established per operation

**Template - Performance Requirements:**
```
Endpoint: POST /api/orders
SLA:
  - p50 response time: <200ms
  - p95 response time: <500ms
  - p99 response time: <1000ms
  - Throughput: >1000 req/sec
  - Error rate: <0.1%
Resource Limits:
  - CPU: <70% utilization
  - Memory: <80% utilization
  - DB connections: <80% of pool
Test Scenarios:
  - Baseline: 100 concurrent users, 5 min duration
  - Peak: 500 concurrent users, 10 min duration
  - Stress: 1000 concurrent users, until failure
```

### Step 2: Design Performance Test Scenarios

**Actions:**
- Create realistic workload models based on production traffic patterns
- Design test scenarios for baseline, load, stress, and spike testing
- Define test data requirements and data generation strategy
- Plan monitoring and metrics collection

**Checklist:**
- [ ] Workload model based on production traffic analysis
- [ ] Test scenarios: baseline, load, stress, spike, endurance
- [ ] Test data generated with realistic distribution
- [ ] Monitoring tools configured (APM, infrastructure metrics)
- [ ] Metrics collection pipeline established
- [ ] Test environment matches production topology

### Step 3: Implement Performance Tests

**Actions:**
- Select performance testing tool (k6, JMeter, Gatling, Locust)
- Implement test scripts with realistic user behavior
- Configure think times, pacing, and ramp-up patterns
- Implement custom metrics and assertions

**Checklist:**
- [ ] Performance testing tool selected and configured
- [ ] Test scripts implement realistic user flows
- [ ] Think times and pacing match production patterns
- [ ] Ramp-up/ramp-down patterns configured
- [ ] Custom metrics defined (business KPIs)
- [ ] Assertions for SLA validation
- [ ] Correlation and parameterization implemented

**Template - k6 Performance Test:**
```javascript
import http from 'k6/http';
import { check, sleep } from 'k6';
import { Rate } from 'k6/metrics';

const errorRate = new Rate('errors');

export const options = {
  stages: [
    { duration: '2m', target: 100 },   // Ramp up
    { duration: '5m', target: 100 },   // Steady state
    { duration: '2m', target: 500 },   // Spike
    { duration: '5m', target: 500 },   // Peak load
    { duration: '2m', target: 0 },     // Ramp down
  ],
  thresholds: {
    http_req_duration: ['p(95)<500'],
    errors: ['rate<0.01'],
  },
};

export default function () {
  const res = http.post('https://api.example.com/orders', JSON.stringify({
    items: [{ productId: '123', quantity: 2 }],
  }), {
    headers: { 'Content-Type': 'application/json' },
  });

  check(res, {
    'status is 201': (r) => r.status === 201,
    'response time < 500ms': (r) => r.timings.duration < 500,
  });

  errorRate.add(res.status !== 201);
  sleep(1);
}
```

### Step 4: Execute Performance Tests

**Actions:**
- Provision test environment matching production
- Execute tests with monitoring active
- Collect metrics during test execution
- Monitor for anomalies and bottlenecks

**Checklist:**
- [ ] Test environment provisioned and validated
- [ ] Monitoring dashboards active (APM, infra, DB)
- [ ] Tests executed per scenario plan
- [ ] Real-time monitoring during execution
- [ ] Anomalies logged with timestamps
- [ ] Resource utilization captured

### Step 5: Analyze Results and Optimize

**Actions:**
- Analyze performance metrics against SLAs
- Identify bottlenecks (code, database, network, infrastructure)
- Generate performance report with findings
- Provide optimization recommendations

**Checklist:**
- [ ] Results compared against SLA thresholds
- [ ] Bottlenecks identified with root cause
- [ ] Performance report generated with charts
- [ ] Optimization recommendations prioritized
- [ ] Regression tests added for performance
- [ ] Baseline updated with new metrics

## Success Metrics

| Metric | Target | Measurement |
|--------|--------|-------------|
| SLA Compliance | >99% of requests meet SLA | Requests within SLA / Total requests |
| p95 Response Time | <500ms for critical paths | 95th percentile response time |
| Throughput | Meet or exceed requirements | Requests per second |
| Error Rate Under Load | <0.1% | Errors / Total requests under load |
| Resource Utilization | <70% CPU, <80% memory | Peak utilization during tests |
| Performance Regression | 0 regressions in critical paths | Current vs baseline comparison |

## Error Handling

### Error 1: Test Environment Performance Differs from Production
**Symptoms:** Performance results don't match production behavior
**Resolution:**
1. Compare environment specs (CPU, memory, network, storage)
2. Validate database size and index parity with production
3. Check for resource contention (noisy neighbors)
4. Use production traffic replay if possible
5. Apply environment scaling factor to results

### Error 2: Performance Test Causes Service Outage
**Symptoms:** System becomes unresponsive during stress testing
**Resolution:**
1. Implement circuit breakers and auto-scaling limits
2. Set up health check monitoring with auto-stop triggers
3. Use gradual ramp-up to identify breaking point
4. Coordinate with ops team before stress tests
5. Implement graceful degradation in test scripts

### Error 3: Inconsistent Performance Results
**Symptoms:** Same test produces different results across runs
**Resolution:**
1. Eliminate external variables (network, shared resources)
2. Use dedicated test environment (no other workloads)
3. Increase test duration to smooth out variance
4. Run multiple iterations and use statistical analysis
5. Check for garbage collection pauses and warm-up effects

## Cross-Team Integration

- **load-Load-testing**: Coordinate on sustained load testing and capacity validation
- **loadtester-qualityforge-scalability-testing**: Share findings on system scaling behavior
- **profiler-Performance-profiler**: Provide performance data for detailed profiling
- **automation-qualityforge-test-automation**: Integrate performance tests into CI/CD pipeline
- **monitor-qualityforge-quality-monitor**: Feed performance metrics into quality dashboards
- **reporter-qualityforge-quality-reporter**: Provide performance test results for quality reporting

