Skip to main content
Skip to main content

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

High Impact

Number of stacks and resources to analyze

Optimization: Use service filtering and incremental analysis

Network Speed

Medium Impact

AWS API calls and data transfer

Optimization: Enable caching and reduce API calls

System Resources

Medium Impact

CPU, memory, and disk usage

Optimization: Adjust concurrency and enable caching

Analysis Depth

Low Impact

Level of detail in analysis

Optimization: Use severity thresholds and custom rules

Optimization Strategies

Service Filtering

High Impact

Limit 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 Impact

Cache 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 Impact

Adjust 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 Impact

Focus 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 seconds

Fast 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 minutes

Comprehensive analysis for deployments

Configuration:

{
  "services": [],
  "severityThreshold": "high",
  "cacheEnabled": false,
  "outputFormat": "json",
  "maxConcurrency": 4
}

Use Case: Automated security checks

Security Audit

5-15 minutes

Complete security analysis

Configuration:

{
  "services": [],
  "severityThreshold": "low",
  "cacheEnabled": true,
  "cacheTTL": 3600,
  "includeRecommendations": true
}

Use Case: Comprehensive security reviews

Quick Check

10-30 seconds

Rapid 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 scan

Benefit: Identify performance bottlenecks

Check Cache Hit Rate

Monitor cache effectiveness

npx cdk-insights cache:status

Benefit: 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 --follow

Benefit: 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,Lambda

2. Enable Intelligent Caching

Use caching to dramatically speed up subsequent analysis runs, especially during development.

npx cdk-insights scan --cache-enabled --skip-unchanged

3. 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 high

4. Monitor and Adjust

Regularly monitor performance metrics and adjust configuration based on your project's evolution and requirements.

npx cdk-insights cache:status

Ready to Optimize Performance?

Start implementing these optimization strategies to improve your CDK Insights analysis speed and efficiency.