Troubleshooting Performance Issues in AWS Lambda
Instruction: Describe a systematic approach to diagnosing and resolving performance issues in AWS Lambda functions.
Updated
Official answer
Start with the observed symptom and denominator: which version, input class and percentile became slow, at what request rate? Compare client latency or event freshness with Lambda Duration; Duration excludes cold-start initialization and does not include the entire upstream queueing path.
Check source backlog, throttles, concurrency and deployment timing. Low handler duration with growing queue age suggests a capacity or delivery bottleneck, not necessarily slow code. A duration increase alone does not identify the cause; larger inputs or a slower dependency may explain it.
Use sanitized structured logs and sampled traces to split initialization, handler work and dependency calls. Investigate CPU/memory pressure, connection churn, DNS/network failures, service rate limits and retries. Increasing memory increases allocated CPU and may improve some I/O workloads, but does not guarantee a proportional network-speed increase or repair a saturated database.
Reproduce with comparable inputs and load, then vary one factor: memory, algorithm, dependency call pattern, batching or concurrency. Record p50/p95/p99 as relevant, error rate, completed-work count and cost. For example, reducing parallel database calls may improve tail latency by avoiding connection exhaustion even though it lowers instantaneous concurrency.
Verify under sustained and burst load, including cold environments and failures. Use a gradual release with rollback. Raising the timeout without explaining the delay can convert a visible failure into a longer, more expensive failure.