Zero cold start for lambda?

Hi there,

There are other FaaS out there (which different sets of tradeoffs, I know) that are marketing their Zero Cold start (for TypeScript, Javascript, and WASM).

Is AWS still investing to reduce (eliminate) cold start for Lambda (TS, JS, and WASM) as they now provide PC (which I view as a “hack” and one more thing to think about)?

Maybe for step functions, it could “pre-warn” the possible “next lambdas” if there are not yet available VMs and many other “clever” tricks that would abstract away the cold start from us developers.

Zero cold start FaaS is especially important when having small lambdas calling each other (orchestration through Step Functions)

Any help would be appreciated.

UPDATE: Interesting documents/discussions:https://dashbird.io/blog/can-we-solve-serverless-cold-starts/https://arxiv.org/abs/2108.13592

Thanks

If you’re concerned about cold starts, why don’t you want to use provisioned concurrency? It does exactly what you’re looking for, it keeps concurrent environments initialized and ready to handle invocations at all times. You can throw auto scaling on that too if you have a predictable load pattern. For most runtimes the coldstart time is almost entirely a function of your initialization code anyway so nobody can really eliminate that without some form of pre-provisioning the instances

i really don’t get this cold start issue at all. in my experience, python cold starts are unnoticeable. i’m assuming the same for js and custom. the cold starts are your initialization code, make it faster.

these home-grown pre warming tactics are only good for some cases. if you reach the frequency when upscale happens, you will have a cold start.

Yes you don’t understand the issue, python has some init to do, its quick not noticeable, its not the same for the underlying infra, that lambda need to start somehow and that would add latency, latency you wouldn’t have with already running instances exemple. Keeping lambda war is cool (pun intended) but the issue will return with scaling.

This is the way.
It will cost you some money though and so needs to be considered carefully

Maybe for step functions, it could “pre-warn” the possible “next lambdas” if there are not yet available VMs and many other “clever” tricks that would abstract away the cold start from us developers.

Serious question, do you think they don’t do this already? That they’re just running with a static fleet of Lambda servers?

Cold starts happen mostly from shock load sucking up all the available compute. Provisioned concurrency solves your issue. If you’re sufficiently concerned about your 4, 5, or 6-nines latency then it’s money well spent.

Thanks for answering!

PC is the only option today, yes. But not having to care about cold starts and managing the number of warm Lambdas makes a few things easier (like ephemeral test environments).
Not having to care about (and manage) pre-warmed instances, instance sizes (128MB or 3GB ram?), and CPU architecture (Arm vs X86) would make lambda even more “Serverless”, right? This is something that AWS should never stop pursuing.

Thanks

I don’t know, but I believe they don’t (if they did they would charge us for pre-warming lambdas that might the “next lambda” to be (or not) executed).

Cold starts happen:

- First time your lambda is invocated after ANY deploy of this function

- When you need more lambdas in parallel than the warm ones

- When AWS needs to patch their fleet of VMs (and they kill your warm lambdas)

- When going over the limit of (500 lambdas)… and in this case, the warm-up is more like MINUTES instead of milliseconds.

I love lambda already, and that is why I want to see it become even better and more awesome.

Thanks

like ephemeral test environments

Cold starts are measured in milliseconds.

You can cold start a python lambda and still make a web response in less than half a second.

I do not see this being a concern for ephemeral environments at all.

Some corrections on your assumptions of cold start behavior:

First time your lambda is invocated after ANY deploy of this function

Yes

When you need more lambdas in parallel than the warm ones

Yes again

When AWS needs to patch their fleet of VMs (and they kill your warm lambdas)

No, this isn’t a thing. Your function is constantly cycling across execution environments, execution environments live about 2 hours max. Less if they aren’t actively being hit

When going over the limit of (500 lambdas)… and in this case, the warm-up is more like MINUTES instead of milliseconds.

I assume you’re referring to burst concurrency here. And yes there is a limitation (though it varies per region) but this doesn’t really have anything to do with warm/cold starts. This is all about scaling quotas (and if this is a limitation you should move to a region with a higher limit or get a limit increase)

I don’t really think you can just magically abstract all of this stuff away though, that would also take away a ton of control. Sure AWS could manage provisioned concurrency for everyone and have it on all the time, but that would just increase costs across the board. How is Lambda supposed to know how much RAM you need? Sure it could just keep increasing it until your function stops running out of memory, but that wouldn’t account for a ton of different scenarios that you would know better as the developer. Same thing for Arm or X86, is this really such a burden to choose when you create the function? You know what platform you developed for

Cold start^* times by language from a recent run of my hello world lambdas (these are raw results for a single execution each, not aggregated data, so not statistically validated)

Dotnet core: 179 ms
Golang: 82 ms
Java Coretto: 774 ms
Java 8 (not coretto): 520 ms
Java 11: 487 ms
Nodejs 10: 150 ms
Nodejs 12: 173 ms
Python 2.7: 92 ms
Python 3.7: 138 ms
Python 3.8: 124 ms
Ruby 2.5: 150 ms
Ruby 2.7: 421 ms

Java isn’t great for some use cases, nor is one version of Ruby, which may be an outlier.

But Go cold starts so fast you would have to check the logs to know if it cold started or not compared to other warm lambdas.

^* For clarification, these measurements are the Lambda initialization times, not the full invocation time of the functions.

See my top level comment, python does just fine on cold starts.
Now Java, thats another story.

I think this is something that AWS should be working on. I agree that this might not be the best option today. But I think this can be pulled off in the future.

I am not saying that today’s way is bad, I just think more abstraction can be created to improve the ease of use of Lambdas and other Serverless components. Thanks for contributing to the discussion.

Lambdas that call other lambdas might be affected even more. Latency is getting more and more important for user experience these days… the 99.5 percentile. So if AWS can reduce the Cold Start of lambda (at least on the part that they control) everybody would be happier, I think.

I can’t imagine any AWS customer saying: “F*** Y** AWS! The cold starts are too fast/short, please make it slower, please”. And please, I love Lambda and AWS Serverless in general, don’t get me wrong.

Thanks for contributing

See “Understanding how functions warmers work”: https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-1/

Looking at this, it sort of blows my mind a bit, because I believe your numbers but in practice this doesn’t “feel” right. I guess these numbers are the minimum amount of time, but also there may (in many cases I’d guess?) be additional “bootstrapping” that happens? e.g. if some service needs to be initialized, etc?

https takes more time

yeah, no. lambdas should not call lambdas this way, and platforms should not be optimized for antipatterns.