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?
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With