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
asked 8 months ago114 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions