Why running a lambda with custom image for the first time takes more time?

0

Hi,

I noticed the first time I am calling a lambda with a new custom image the "init duration" is usually between 3500 ms to 9600 ms. When not called for few minutes or days the cold start calls will have "init duration" between 800 ms to 2000 ms. It looks like the first cold start call is doing much more work than the subscequent calls. Are there optimisations happening or something during that first time only? For example, are the image layers cached for for faster access next time?

According to https://docs.aws.amazon.com/lambda/latest/operatorguide/execution-environments.html#cold-start-latency, customers are not supposed to be charged for the first 2 steps "download code" and "start new execution environment". Why are customers charged for that extra work/latency in the "init" the first time (see screenshot below)?

Lambda billed duration very high the first time only

Note there is no initiatlization code in the function used for testing https://github.com/Ducharme/awsCustomLambdas (node:20-bookworm with PROJECT_NAME=salut in config file set_project_values.sh)

Claude
demandé il y a 8 mois120 vues
Aucune réponse

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