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 :)

質問済み 3ヶ月前194ビュー
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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ