mikhailshilkov / mikhailio-hugo

Sources of https://mikhail.io migrated to Hugo
MIT License
12 stars 8 forks source link

More reasons for Cold-Start? #22

Open yshemesh opened 5 years ago

yshemesh commented 5 years ago

In addition to the time it takes to load a new functions based on its Image-Size, What about the following scenario: Fast Scaling that involves allocating new ec2 instances. Lambda function has a per instance initialization/bootstrapping: When a Lambda function is first invoked in an instance, AWS Lambda launches an "execution context" which is a temporary runtime environment that initializes any external dependencies of the function code, such as database connections, HTTP endpoints, local disk space for transient cache "/tmp" directory (content remains when the execution context is frozen).

Also did anyone test how fast Lambda scales, in the past there have been many issues with very busty traffic in ELB not being able to scale fast enough?

mikhailshilkov commented 5 years ago

Well, Lambda doesn't start EC2 instances on demand while a request is waiting. They keep a bunch of instances in the pool shared for a bunch of clients, all booted, runtime loaded, jitted if needed, etc. It's just the bit that is specific to each lambda that they have to put on demand.

I believe the duration of a cold starts while scaling from 0 to 1 and from N to N+1 are similar.

Regarding rapid scale out, I have these two pieces: one and two. However, there's no ELB there: the HTTP test uses API Gateway.