BMAD-METHOD/bmad-agent/tasks/performance-analysis-task.md

285 lines
8.5 KiB
Markdown

# Performance Analysis Task
## Task Overview
**Task ID:** performance-analysis
**Category:** Performance Optimization
**Complexity:** High
**Estimated Duration:** 4-8 hours
**Prerequisites:** Application access, monitoring tools, performance baselines
## Objective
Conduct comprehensive performance analysis across technology stacks to identify bottlenecks, optimization opportunities, and provide actionable recommendations for performance improvements.
## Task Scope
### Technology Coverage
- **Frontend:** React, TypeScript, JavaScript applications
- **Backend:** Node.js, ASP.NET, Python applications
- **Database:** SQL Server, PostgreSQL, MongoDB performance
- **Infrastructure:** Server performance, network latency, CDN optimization
### Analysis Dimensions
1. **Response Time Analysis**
- API endpoint performance
- Page load times
- Database query performance
- Third-party service latency
2. **Resource Utilization**
- CPU usage patterns
- Memory consumption
- Disk I/O performance
- Network bandwidth utilization
3. **User Experience Metrics**
- Core Web Vitals (LCP, FID, CLS)
- Time to Interactive (TTI)
- First Contentful Paint (FCP)
- Cumulative Layout Shift (CLS)
4. **Scalability Assessment**
- Load handling capacity
- Concurrent user limits
- Resource scaling requirements
- Performance degradation patterns
## Task Execution Steps
### Phase 1: Performance Baseline Establishment (1-2 hours)
\```yaml
baseline_metrics:
frontend:
- page_load_times: "measure across key pages"
- core_web_vitals: "LCP, FID, CLS measurements"
- bundle_sizes: "JavaScript, CSS bundle analysis"
- network_requests: "count, size, timing analysis"
backend:
- api_response_times: "P50, P95, P99 percentiles"
- throughput: "requests per second"
- error_rates: "4xx, 5xx error percentages"
- resource_usage: "CPU, memory, disk utilization"
database:
- query_performance: "slow query identification"
- connection_pooling: "connection usage patterns"
- index_efficiency: "index usage analysis"
- lock_contention: "blocking and deadlock analysis"
```
### Phase 2: Bottleneck Identification (2-3 hours)
\```typescript
// Performance profiling approach
interface PerformanceBottleneck {
component: string;
severity: 'critical' | 'high' | 'medium' | 'low';
impact: string;
metrics: {
current_performance: number;
target_performance: number;
improvement_potential: number;
};
root_cause: string;
optimization_complexity: 'low' | 'medium' | 'high';
}
const identifyBottlenecks = async (): Promise<PerformanceBottleneck[]> => {
return [
{
component: "API endpoint /users",
severity: "critical",
impact: "95th percentile response time: 3.2s (target: <1s)",
metrics: {
current_performance: 3200,
target_performance: 1000,
improvement_potential: 68
},
root_cause: "N+1 query pattern in user data fetching",
optimization_complexity: "medium"
}
];
};
```
### Phase 3: Technology-Specific Analysis (2-3 hours)
#### Frontend Performance Analysis
\```javascript
// React performance analysis
const analyzeReactPerformance = () => {
return {
component_rendering: {
unnecessary_rerenders: "identify with React DevTools Profiler",
large_component_trees: "analyze component hierarchy depth",
expensive_calculations: "identify non-memoized computations"
},
bundle_optimization: {
code_splitting: "analyze bundle splitting opportunities",
tree_shaking: "identify unused code elimination",
lazy_loading: "assess component lazy loading potential"
},
network_optimization: {
api_calls: "analyze request patterns and caching",
asset_optimization: "image, font, and static asset analysis",
cdn_usage: "evaluate CDN effectiveness"
}
};
};
```
#### Backend Performance Analysis
```python
# Python/Node.js performance analysis
def analyze_backend_performance():
return {
"cpu_profiling": {
"hot_spots": "identify CPU-intensive functions",
"event_loop_blocking": "detect blocking operations",
"async_optimization": "evaluate async/await usage"
},
"memory_analysis": {
"memory_leaks": "detect memory leak patterns",
"garbage_collection": "analyze GC pressure",
"object_pooling": "evaluate object reuse opportunities"
},
"database_optimization": {
"query_optimization": "analyze slow queries",
"connection_pooling": "evaluate connection efficiency",
"caching_strategy": "assess caching effectiveness"
}
}
```
#### .NET Performance Analysis
```csharp
// .NET performance analysis
public class DotNetPerformanceAnalysis
{
public PerformanceReport AnalyzeApplication()
{
return new PerformanceReport
{
MemoryAnalysis = new MemoryAnalysis
{
GCPressure = AnalyzeGarbageCollection(),
LargeObjectHeap = AnalyzeLOHUsage(),
ObjectPooling = EvaluateObjectPooling()
},
JitOptimization = new JitAnalysis
{
CompilationTime = MeasureJitCompilation(),
TieredCompilation = AnalyzeTieredJit(),
ReadyToRun = EvaluateR2RBenefits()
},
AsyncPatterns = new AsyncAnalysis
{
TaskUsage = AnalyzeTaskPatterns(),
ConfigureAwait = CheckConfigureAwaitUsage(),
SynchronizationContext = AnalyzeSyncContext()
}
};
}
}
```
### Phase 4: Optimization Recommendations (1-2 hours)
\```yaml
optimization_recommendations:
high_impact_low_effort:
- enable_gzip_compression: "30-70% size reduction"
- implement_browser_caching: "repeat visit performance"
- optimize_images: "WebP format, lazy loading"
- database_index_optimization: "query performance improvement"
medium_impact_medium_effort:
- implement_code_splitting: "reduce initial bundle size"
- add_service_worker_caching: "offline performance"
- optimize_database_queries: "reduce N+1 patterns"
- implement_connection_pooling: "database efficiency"
high_impact_high_effort:
- migrate_to_microservices: "scalability improvement"
- implement_caching_layer: "Redis/Memcached integration"
- optimize_algorithms: "computational efficiency"
- infrastructure_scaling: "horizontal scaling implementation"
```
## Deliverables
### 1. Performance Analysis Report
\```markdown
# Performance Analysis Report
## Executive Summary
- Current performance status
- Key bottlenecks identified
- Optimization opportunities
- Expected improvement impact
## Detailed Findings
- Technology-specific analysis
- Performance metrics and trends
- Root cause analysis
- Comparative benchmarks
## Optimization Roadmap
- Prioritized recommendations
- Implementation timeline
- Resource requirements
- Success metrics
```
### 2. Performance Monitoring Dashboard
- Real-time performance metrics
- Historical trend analysis
- Alert configuration
- Performance SLA tracking
### 3. Optimization Implementation Plan
- Step-by-step optimization guide
- Code examples and best practices
- Testing and validation procedures
- Rollback strategies
## Quality Validation
### Performance Metrics Validation
- [ ] Baseline metrics accurately captured
- [ ] Bottlenecks properly identified and prioritized
- [ ] Optimization recommendations are actionable
- [ ] Expected improvements are quantified
- [ ] Implementation complexity is assessed
### Technical Validation
- [ ] Analysis covers all technology stacks
- [ ] Profiling data is comprehensive
- [ ] Root cause analysis is thorough
- [ ] Recommendations align with best practices
- [ ] Monitoring strategy is complete
### Business Impact Validation
- [ ] User experience impact is quantified
- [ ] Business metrics are considered
- [ ] Cost-benefit analysis is provided
- [ ] Implementation timeline is realistic
- [ ] Success criteria are defined
## Integration Points
- **Architect:** Performance requirements integration
- **Developer:** Optimization implementation guidance
- **DevOps:** Infrastructure and monitoring setup
- **QA:** Performance testing strategy
## Success Metrics
- Performance improvement percentages
- Response time reductions
- Resource utilization optimization
- User experience score improvements
- System reliability enhancements
## Follow-up Actions
- Schedule optimization implementation
- Set up performance monitoring
- Plan performance testing
- Establish ongoing performance reviews