Interview Prep/AWS/ECS, EKS, ECR and Lambda

Lambda logs end with `Task timed out after 3.00 seconds`.

BeginnerTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → The default timeout is 3 seconds. The function is slow, or it hangs on a network call: a VPC function with no route to the internet or endpoint, a DB connection without a timeout, or a downstream that is slow.

Diagnose →

aws lambda get-function-configuration --function-name orders-api --query '[Timeout,MemorySize,VpcConfig]'
aws logs tail /aws/lambda/orders-api --since 15m
# enable X-Ray active tracing to see which segment takes the time

Fix →

  1. Set client timeouts on every network call below the function timeout
  2. Raise the timeout to a realistic value: aws lambda update-function-configuration --function-name orders-api --timeout 15
  3. Raising memory also gives more CPU, which speeds up CPU-bound code

Prevent → Alarm on the Duration p99 against the timeout, and turn on X-Ray tracing.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on ECS, EKS, ECR and Lambda