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 個月前檢視次數 195 次
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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南