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

demandé il y a 3 mois195 vues
4 réponses
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
EXPERT
répondu il y a 3 mois
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
EXPERT
répondu il y a 3 mois
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.

répondu il y a 3 mois
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).

répondu il y a 3 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions