Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Task timed out after 6.00 seconds

I am using serverless framework. My Lambda function connects to DynamoDB table for updating item in table. Read & Write capacity units of table are 5 & auto_scaling is disabled. AWS Lambda function has 128MB memory allocated.

I have used Jmeter for performance testing.I have sent 1000 requests concurrently and some response giving me perfect output while other giving internal server error(502 Bad Gateway). i have also analyzed cloudwatch for logs and only get Task Timeout error. can anyone suggest me why i am getting this error and how to solve it?

like image 281
darshi kothari Avatar asked Dec 01 '17 13:12

darshi kothari


People also ask

Why does my Lambda keep timing out?

There are three reasons why retry and timeout issues occur when invoking a Lambda function with an AWS SDK: A remote API is unreachable or takes too long to respond to an API call. The API call doesn't get a response within the socket timeout.

Why is my Lambda timing out after 3 seconds?

The default timeout of a Lambda function is three seconds. This means, if you don't explicitly configure a timeout, your function invocations will be suspended after three seconds. Now, if you call a few services, some of which are currently at capacity, a request can very well take a second on its own.

How do I increase Lambda timeout limit?

You cannot increase the runtime to more than 15 minutes. The AWS Lambda limit page states the Function timeout is 900 seconds (15 minutes) . If you need more than 15 minutes of execution time you have to look at other services. You could have a look if AWS Batch would suit your needs.


1 Answers

The default timeout for AWS Lambda functions when using the Serverless framework is 6 seconds. Simply change that to a higher value as noted in the documentation:

functions:   hello:     ...     timeout: 10 # optional, in seconds, default is 6 
like image 83
Dunedan Avatar answered Sep 19 '22 13:09

Dunedan