Performance Optimization
Optimize CDK Insights performance for large projects and complex infrastructures. Learn strategies to reduce analysis time and resource usage while maintaining comprehensive coverage.
Performance Factors
Project Size
Number of stacks and resources to analyze
Optimization: Use service filtering and incremental analysis
Network Speed
AWS API calls and data transfer
Optimization: Enable caching and reduce API calls
System Resources
CPU, memory, and disk usage
Optimization: Adjust concurrency and enable caching
Analysis Depth
Level of detail in analysis
Optimization: Use severity thresholds and custom rules
Optimization Strategies
Service Filtering
High ImpactLimit analysis to specific AWS services
Configuration:
{
  "services": ["S3", "IAM", "Lambda"]
}Benefits:
- Reduces analysis scope by 60-80%
- Faster execution for large projects
- Focus on critical services only
Best for: Large projects with many services
Caching
High ImpactCache analysis results for reuse
Configuration:
{
  "cacheEnabled": true,
  "cacheTTL": 7200,
  "skipUnchangedFiles": true
}Benefits:
- 90% faster subsequent runs
- Reduced AWS API calls
- Lower resource usage
Best for: Development workflows with frequent scans
Concurrency Control
Medium ImpactAdjust parallel processing threads
Configuration:
{
  "maxConcurrency": 4
}Benefits:
- Balanced CPU usage
- Prevents memory exhaustion
- Configurable for different systems
Best for: Systems with limited resources
Severity Filtering
Medium ImpactFocus on high-priority issues only
Configuration:
{
  "severityThreshold": "high"
}Benefits:
- Reduced output processing
- Faster result generation
- Focus on critical issues
Best for: Quick security assessments
Recommended Performance Profiles
Development
30-60 secondsFast feedback during development
Configuration:
{
  "services": [
    "S3",
    "IAM",
    "Lambda"
  ],
  "severityThreshold": "medium",
  "cacheEnabled": true,
  "cacheTTL": 1800,
  "maxConcurrency": 2
}Use Case: Daily development workflow
CI/CD Pipeline
2-5 minutesComprehensive analysis for deployments
Configuration:
{
  "services": [],
  "severityThreshold": "high",
  "cacheEnabled": false,
  "outputFormat": "json",
  "maxConcurrency": 4
}Use Case: Automated security checks
Security Audit
5-15 minutesComplete security analysis
Configuration:
{
  "services": [],
  "severityThreshold": "low",
  "cacheEnabled": true,
  "cacheTTL": 3600,
  "includeRecommendations": true
}Use Case: Comprehensive security reviews
Quick Check
10-30 secondsRapid issue identification
Configuration:
{
  "services": [
    "S3",
    "IAM"
  ],
  "severityThreshold": "critical",
  "cacheEnabled": true,
  "cacheTTL": 3600,
  "maxConcurrency": 1
}Use Case: Pre-deployment checks
Performance Monitoring
Monitor Analysis Time
Track how long analysis takes for different project sizes
time npx cdk-insights scanBenefit: Identify performance bottlenecks
Check Cache Hit Rate
Monitor cache effectiveness
npx cdk-insights cache:statusBenefit: Optimize caching strategy
Profile Resource Usage
Monitor CPU and memory usage during analysis
top -p $(pgrep -f cdk-insights)Benefit: Identify resource constraints
Measure Network Calls
Track AWS API call frequency
aws logs tail /aws/lambda/cdk-insights --followBenefit: Optimize API usage patterns
Performance Best Practices
1. Start with Service Filtering
For large projects, begin by limiting analysis to the most critical services. This can reduce analysis time by 60-80%.
npx cdk-insights scan --services S3,IAM,Lambda2. Enable Intelligent Caching
Use caching to dramatically speed up subsequent analysis runs, especially during development.
npx cdk-insights scan --cache-enabled --skip-unchanged3. Use Appropriate Severity Thresholds
Set severity thresholds based on your use case. Critical issues for quick checks, all issues for comprehensive audits.
npx cdk-insights scan --severity-threshold high4. Monitor and Adjust
Regularly monitor performance metrics and adjust configuration based on your project's evolution and requirements.
npx cdk-insights cache:statusReady to Optimize Performance?
Start implementing these optimization strategies to improve your CDK Insights analysis speed and efficiency.