48Testing TypesPerformanceMetrics
What are the key metrics to measure in performance testing?
Key Performance Metrics
1. Response Time:
- Time taken to receive response after sending request
- Measured in milliseconds or seconds
- Target: < 2 seconds for web pages, < 500ms for APIs
2. Throughput:
- Number of requests processed per unit time
- Measured in requests/second or transactions/second
- Higher throughput = better performance
3. Concurrent Users:
- Number of users accessing system simultaneously
- Tests system capacity
- Example: 1000 concurrent users
4. Error Rate:
- Percentage of failed requests
- Target: < 1% error rate
- Includes HTTP errors (500, 503, etc.)
5. CPU Utilization:
- Percentage of CPU being used
- Target: < 70-80% under normal load
- High CPU may indicate performance bottleneck
6. Memory Usage:
- Amount of RAM consumed
- Monitor for memory leaks
- Should remain stable over time
7. Network Bandwidth:
- Data transfer rate
- Measured in Mbps or Gbps
- Important for data-heavy applications
8. Database Performance:
- Query execution time
- Connection pool usage
- Database locks and deadlocks
Performance Testing Types
Load Testing:
- Test system under expected load
- Example: 500 concurrent users
Stress Testing:
- Test system beyond normal capacity
- Find breaking point
Spike Testing:
- Sudden increase in load
- Example: Black Friday traffic
Endurance Testing:
- Test system over extended period
- Detect memory leaks
Performance Testing Tools
- JMeter: Open-source load testing tool
- LoadRunner: Enterprise performance testing
- Gatling: Modern load testing framework
- K6: Developer-centric load testing
- Locust: Python-based load testing
Acceptable Performance Benchmarks
- Page load time: < 3 seconds
- API response time: < 500ms
- Database query: < 100ms
- Error rate: < 1%
- CPU usage: < 80%