Skip to content
Cloud Efficiency Hub

Excessive Lambda Duration from Synchronous Waiting

The short version

Some Lambda functions perform synchronous calls to other services, APIs, or internal microservices and wait for the response before proceeding.

Igor Bareev

Sr TAM @ Amazon Web Services (AWS)

AWS service
AWS Lambda
Category
Compute
Reference
CER-0230
Type
Inefficient Configuration

Explanation

Why the waste happens and who it affects.

During this time, the Lambda is idle from a compute perspective but still fully billed. This anti-pattern can lead to unnecessarily long durations and elevated costs, especially when repeated across high-volume workflows or under memory-intensive configurations.

While this behavior might be functionally correct, it is rarely optimal. Asynchronous invocation patterns - such as decoupling downstream calls with queues, events, or callbacks-can reduce runtime and avoid charging for waiting time. However, detecting this inefficiency is nontrivial, as high duration alone doesn't always indicate synchronous waiting. Understanding function logic and workload patterns is key.

Billing model

The pricing dimensions that drive this cost.

Lambda costs are based on two primary dimensions: the number of requests, and duration, measured in GB-seconds (allocated memory multiplied by execution time, rounded up to the nearest 1 ms). Duration runs from the time the code begins executing until it returns or otherwise terminates, so time spent waiting on a synchronous downstream call is billed the same as active compute.

How to detect

6 checks to find it in your estate.

  • Review Lambda functions with consistently high average or p95 durations relative to expected execution complexity
  • Identify functions that invoke external services or APIs synchronously
  • Check whether long execution times correspond to periods of low CPU or memory utilization
  • Evaluate whether downstream systems could be decoupled or moved to an async pattern
  • Consult application owners to confirm whether waiting time is built into function logic
  • Correlate duration spikes with network latency or known API response delays

How to fix

4 ways to remove the waste.

  • Redesign functions to offload synchronous calls using asynchronous patterns (e.g., queues, event buses, Step Functions), or use Lambda durable functions, whose wait operations suspend execution so on-demand functions are not billed duration while waiting
  • Break apart long-running workflows into smaller chained or event-driven Lambdas
  • Optimize memory allocation to minimize idle cost when waiting cannot be avoided
  • Include async design principles in serverless architecture reviews

Documentation

Vendor references for pricing and configuration.