Lambda randomly times out

0

Hello,

My lambda function randomly times out, and the output logs are weird: Enter image description here

As you can see, the Start and End timestamps are 1706515729145 1706515729767

which are about 600ms apart. However, the logs say the task times out after 5s (which in itself is really surprising, as the lambda does nothing except parse a small string into JSON, and send it to an SQS queue). This happens randomly (maybe once in 10k / 20k invocations).

Any clue as what might be happening here?

Thanks :)

4개 답변
1

Increase the Lambda timeout. It can be configured up to 15 mins. It looks like yours is set to 5 seconds. It may be it just needs a few more seconds for your code to finishing executing

https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-timeout-console

profile picture
전문가
답변함 3달 전
1

The Coldstart is also included in the total execution time. It may be because your function warms up the first time and on the 2nd run its already started so runs instantly without a cold start.. I believe you can review the warm up time. May also be worth enabling Lambda Insights for more information

I still recommend increasing time out.

profile picture
전문가
답변함 3달 전
0

Thanks for your reply! The 5s timeout is totally fine, as the process is usually done in a few hundreds of milliseconds. Even in this case, the time elapsed between start and end of the request is about 600ms and should not have triggered a "timed out" error, which is what I'm worried about here.

답변함 3달 전
0

Thanks for the insight.

According to the docs, "You are not charged for the time it takes for Lambda to prepare the function but it does add latency to the overall invocation duration." (see https://docs.aws.amazon.com/lambda/latest/operatorguide/execution-environments.html). However, the "billed duration" is at 5s, so it can't be caused by the cold start of the function (and a cold start time of 4s would be extremely surprising for such a small NodeJS function).

답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠