INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

Topic lessonTopic: Lambda and API Gateway: inputs, testing and failure investigation

Troubleshoot AWS Lambda timeouts: duration, dependency waits and retries

A Lambda timeout means the function did not finish within its configured deadline; it does not identify the cause. Establish the invocation method and which deadline expired, then investigate input size, downstream waits and function work. Check results and side effects before extending the deadline or invoking again.

What you will learn

Choose the next check from the observed symptom, distinguish caller/function deadlines and retries, and avoid unsupported replays or setting changes.

Prerequisite

Know events, handlers, returns and logs. This guide focuses on Event Functions in the default execution environment. No AWS account is needed; paste no real logs, and create or reconfigure no functions.

First establish which deadline expired

Similar symptoms require different next checks
ObservationWhat it does not establishNext check
Caller connection times outThe function stopped or made no changesOutcome of that request and both deadlines
A function timeout is recordedNetworking was the sole causeInputs and work/wait stages
Synchronous Invoke is 200 with a function errorThe intended work succeededFunctionError and returned result/error
Asynchronous Invoke is 202Completed function outcomeExecution outcome and retry/failure records

Separate the deadline from work duration

The deadline is a configured limit; duration is time actually spent on the work. Ordinary functions covered here use 1–900 seconds, with a 3-second default. Input and dependency variability matter; a limit close to an average duration may leave insufficient margin.

Fixed conditions: compare a 5-second limit with stipulated 8-second work; positions and lines are not a time scale
Fixed conditions: compare a 5-second limit with stipulated 8-second work; positions and lines are not a time scale1: Fixed example — Allowed time — Deadline: 5 s. 2: Fixed example — Assumed work requirement — Stipulated work: 8 s12Fixed exampleDeadline: 5 sStipulated work: 8sFixed conditions: compare a 5-second limit with stipulated 8-second work; positions and lines are not a time scale1: Fixed example — Allowed time — Deadline: 5 s. 2: Fixed example — Assumed work requirement — Stipulated work: 8 s12Fixed exampleDeadline: 5 sStipulatedwork: 8 s
  1. Fixed example → Deadline: 5 sAllowed time
  2. Fixed example → Stipulated work: 8 sAssumed work requirement
Fixed example
Assume synchronous invocation; compare two supplied durations.
Deadline: 5 s
Allowed time; the model expires before completion.
Stipulated work: 8 s
Assumed required work, not an observed completion.
Keep stipulated work at 8 seconds and change only the deadline; these are not measured AWS results
Stipulated workDeadlineFixed-model outcome
8 seconds3 secondsTimeout: stipulated work exceeds the deadline
8 seconds5 secondsTimeout: stipulated work exceeds the deadline
8 seconds10 secondsCompleted: stipulated work is shorter than the deadline

Investigate inputs, waits and work from evidence

  1. Record the function/version or alias, time and invocation method: synchronous, asynchronous or event source mapping.
  2. Correlate the returned result/error and logs for that request. An API 200 or 202 alone is insufficient.
  3. Compare recent changes, input size/count and time spent waiting on dependencies. A small successful test does not establish large-input behavior.
  4. Select a candidate supported by observations. Compare before/after under controlled conditions and verify output and duplicate side effects.
Narrow candidates without declaring an unverified cause
ClueCheckAvoid
Only larger inputs are slowCount, size, values and amount of workDeclaring health from one small sample
A wait follows a downstream callResponse, destination and dependency deadlineTreating every timeout as a security-group issue
Compute or memory pressure is suspectedWork stages, usage and configurationPredicting half the time from twice the memory
Logs are not visibleTime/function/log destination, permissions and delayConcluding the function never ran

Memory configuration also affects allocated CPU, but its effect depends on the work. For VPC-connected functions, investigate routing, traffic controls and name resolution. Match changes to the symptom; opening all permissions or adding NAT indiscriminately is not a diagnostic method.

Worked example: a deadline while awaiting a dependency

Fictional observation notes, not real CloudWatch logs
mode = synchronous
function_deadline = 5 seconds
input = fixed sample
last_observed_stage = downstream request started
function_result = timeout
root_cause = not established

The notes establish a function timeout and the last observed stage: a downstream call. They do not establish a slow dependency, failed connection or unfinished later work. Next inspect the destination, response/error and time interval, and compare with a prior successful case.

A deadline increase is an option after establishing required work and bounded waits. After a change, verify the intended result, duration variability, downstream load and cost implications, rather than only the absence of a timeout. This page explains diagnostic choices and performs no live change.

Before replaying, identify who owns retries

Invocation modes have different error and retry behavior
ModeDistinctionInspect
Direct synchronous invocationLambda does not automatically retry function errors; caller/SDK retries differFunction result, caller configuration and replay history
Asynchronous invocationDefault two extra function-error attempts; configurable 0–2. Throttling differsExecution, event age, failed-event destination and duplicates
Queue/stream event source mappingSource-specific rules; do not reuse the 0–2 settingSource configuration and batch/record handling

Idempotency means designing repeated-event handling to avoid effects such as duplicate orders. For example, a repeated order ID should not create a second completed order. An implementation must also address concurrency, partial failure and record retention; an in-memory ID list alone does not establish correctness.

Choose the next check from the symptom

Choose an option to see the result and explanation.

Can you end the investigation after seeing a synchronous Invoke 200?
Read the answer and reason

Answer: Inspect the function return and FunctionError · Separate observations from what remains unverified.

Choose an option to see the result and explanation.

The caller times out and an order outcome is unknown. What next?
Read the answer and reason

Answer: Check that request’s outcome and duplicate protection · Separate observations from what remains unverified.

Choose an option to see the result and explanation.

In the fixed ordinary-function model, the deadline is 5 s and stipulated work is 8 s. What happens?
Read the answer and reason

Answer: The model times out · Separate observations from what remains unverified.

Choose an option to see the result and explanation.

The last note is “downstream call started,” followed by a timeout. Which cause is established?
Read the answer and reason

Answer: Cause is unknown; inspect the response and wait interval · Separate observations from what remains unverified.

Choose an option to see the result and explanation.

Does setting zero asynchronous function-error retries prevent duplicate processing?
Read the answer and reason

Answer: No guarantee; design for duplicates · Separate observations from what remains unverified.

Choose an option to see the result and explanation.

Should the asynchronous 0–2 retry rule be applied unchanged to an SQS event source mapping?
Read the answer and reason

Answer: Inspect source-specific retry/redelivery conditions · Separate observations from what remains unverified.

Check, then explain in your own words

  1. Identify the invocation method and expired deadline.
  2. Separate evidence for inputs, dependency waits and work.
  3. Change the fixed lab deadline and explain what remains unverified in reality.
Check your understanding: What should you establish before increasing a deadline?

Establish invocation mode, which deadline expired, inputs, work/wait observations, existing results and replay side effects.

Timeout is a symptom rather than an established cause; no response is not evidence that no change occurred.

Sources and conditions checked

The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.