Why cold starts of a lambda with provisioned concurrency are much slower than cold starts of on demand instances?

0

I'm using lambda with ASP.NET in a docker container. Recently I enabled provisioned concurrency, and I found out that cold starts (Init time) for provisioned lambdas are 3-4 times slower than cold starts for OnDemand lambdas. My first thought was that maybe provisioned lambda is doing something extra after the Init that adds time. So, I`ve added some logging to app startup methods and it seems like it's just doing everything slower. Like if its running with less vCPU.

Example of startup times of the same version of Lambda:

Provisioned:

LambdaEntryPoint.CreateHostBuilder took 364ms
Startup.ConfigureServices took 643ms
Startup.Configure took 1395ms

On Demand

LambdaEntryPoint.CreateHostBuilder took 82ms
Startup.ConfigureServices took 172ms
Startup.Configure took 291ms

I'm using AWS_LAMBDA_INITIALIZATION_TYPE variable to identity type of provisioning for logs so there is no mistake.

In this talk (https://www.youtube.com/watch?v=ddg1u5HLwg8&t=683s&ab_channel=AWSEvents) they mention that during cold starts CPU is not throttled to warm up lamdas faster and throttling is applied only during handler invokation. But I`m not even sure if it applies to any lamdas or only to Java runtime.

So far, my only guess is that during deployments with provisioned concurrency CPU is actually throttled (unlike on demand cold start). But I can't find any proof for that in documentation and which makes me think that maybe I`m doing something wrong.

Victor
asked 10 months ago327 views
2 Answers
0
Accepted Answer

I think it is exactly what you say. During cold start you get a boost of CPU. I think you do not get the boost during Provisioned Concurrency initialization.

You can prove this by increasing your function's memory to 1.7GB. In this case you will get approximately the same amount of CPU as the boost you get.

profile pictureAWS
EXPERT
Uri
answered 10 months ago
  • Thank you for confirming. Tested and with more CPU On-Demand instances are still a bit faster but the difference is not that visible (10-20%)

0

Hi, If you look at the diagrams of https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-1/, you will notice that the so-called "Execution Initialization Code" in the post happens as part of lambda execution itself in a cold start while it happens as part of initialization phase with provisioned concurrency. (see the blue squares)

That's 1 reason why its longer wit provisioned concurrency.

Best,

Didier

profile pictureAWS
EXPERT
answered 10 months ago
  • I see what you mean but that would impact only overal 'cold start' metric (because now it runs some extra code). But on top of that I see that the 'Initialization Code' executes 4 times faster when it runs as part of lambda execution itself and is very slow when it runs as part of initialization phase with provisioned concurrency.

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