amazon-web-servicesaws-lambdaaws-lambda-containers

Are AWS Lambda containers reused for different lambda functions?


I am using docker images for my lambda functions as our API with API GateWay. I read a bit about the execution context being persisted across lambda invocations assuming it doesn't go down after idling for too long. My question is, are the containers ONLY reused for the lambda function that invoked it?

For example:


Solution

    • If lambda-func-1 is invoked and ran in which I then invoke lambda-func-2, will the container used to process lambda-func-1 and now sitting idle be used to process lambda-func-2? Or will a new container be spun up, meaning any containers that are idle will only process the function that invoked it?

    The container will not be reused to process lambda-func-2. What we are calling "the container" here includes the Lambda function's code. It doesn't make sense to use lambda-func-1's code, to process a request intended for lambda-func-2.

    • If the latter, what happens if there are 100 containers that have processed lambda-func-1 and sitting idle and 100 lambda invocations for lambda-func-2 come through simulataneously? Will 100 new containers be spun up and the 100 containers that processed lambda-func-1 continue to sit idle?

    That is exactly what will happen.