AWS Lambda: Task timed out after X seconds
When your error message says Task timed out after XX.00 seconds, it means that AWS intentionally stopped the task once it hit a run-time of XX seconds.
Dashbird continuously monitors and analyses your serverless applications to ensure reliability, cost and performance optimisation and alignment with the Well Architected Framework.Product Features Start Free Trial
Error Message: Task timed out after 6.01 seconds Type: LOG EVENT Severity: CRITICAL
Why do I see this?
AWS intentionally stopped a function invocation once it hit a run-time of X seconds.
What does this mean?
Lambda functions are limited to a maximum execution time of 15 minutes. A custom limit can be configured when the Lambda function is created. The limit is in place because Lambda functions are meant to be small and quick rather than large applications.
How do I fix if Lambda task is timed out?
Enable AWS X-ray tracing to get a breakdown of the execution. You can also log out the function’s main activities to understand the timescale and identify bottlenecks inside a function execution.
Increase the timeout limit
The time limit is defined in function configuration and can easily be modified. The maximum limit set by AWS is currently 15 minutes.
Simplify the function
A well-written function usually only does one thing. If you’re executing multiple actions in a single function, it can be useful to consider decoupling that function and breaking it up between multiple functions.
Don’t orchestrate/wait in code
If you’re waiting for a task to execute inside the function or using a function to coordinate between more than one additional task, there is a significant risk that you’ll end up accumulating additional costs and risking timing out. This is not aligned with the best practices of serverless. Consider orchestrating with step functions.
For a detailed read on why this happens and how to solve it step by step, read our Debugging with Dashbird: Lambda Task Timed Out After X Seconds article.
This rule resolution is part of the Dashbird Serverless Well-Architected Reports tool for AWS. Dashbird features a collection of rules and checks continuously applied to your infrastructure, surfacing ways to improve it.
Catch errors and inefficiencies in Lambda and learn the best practice rules for AWS Lambda.
Industry leader in serverless monitoring
Dashbird is a monitoring, debugging and intelligence platform designed to help serverless developers build, operate, improve, and scale their modern cloud applications on AWS environment securely and with ease.