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
質問済み 8ヶ月前120ビュー
回答なし

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

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

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

関連するコンテンツ