Skill 4.3.6

Use AWS AI tools to identify optimization opportunities (for example, performance bottleneck detection, resource usage optimization, code efficiency improvement).

Key Concepts

Code efficiency. Given a function and its performance data, Kiro can identify patterns that waste time or capacity: SDK clients or database connections created inside the handler, sequential calls that could run in parallel, a DynamoDB Scan where a Query on an index would do, loops that make one API call per item instead of a batch call, and large objects loaded in full when a range or projection would do. Steering files can record the team's performance rules, and a hook can flag known anti-patterns when a file is saved.

Resource usage. Lambda REPORT lines show the configured memory, the maximum memory used and the duration of each invocation. An AI assistant can summarise these from a Logs Insights query and suggest a memory setting, which AWS Lambda Power Tuning then confirms by measuring cost and duration across several settings. The same approach applies to ECS task sizes, using CPU and memory utilisation from Container Insights.

Bottleneck detection. CloudWatch investigations correlates rising latency or errors with resource metrics, traces and recent changes, and CloudWatch anomaly detection, which uses machine learning, learns each metric's normal pattern and alarms on deviations without a fixed threshold. X-Ray traces and Application Signals show which dependency adds the latency.

Every suggestion is tested: record a baseline (p50, p95 and p99 latency, errors and cost), apply the change in a test environment, run the same load test and compare. An optimisation that is not measured may simply move the bottleneck or raise cost.