FaaS containerized function memory provision - AWS Lambda

71 Views Asked by At

In Function as a Service platform AWS Lambda, in case my function is executed inside a container:

A. When I provision the memory that my function will require during its execution, do I have to consider that some of the RAM will be consumed by the container? Or is it purely the memory that my function's code will require that I have to provision?

Furthermore, irrespectively of the answer to the above question:

B. In case I provision 8 GiB for the execution of my function, when the function's code is not executing and the container is idle (AWS says that the system usually keeps the container idle in memory for a non-deterministic amount of time, after the function's execution, for example between 5 - 15 minutes), will the system keep reserved the 8 GiB that I provisioned for the function or just the memory required for keeping the container in memory?

C. What is usually the average RAM required for an idle container? I understand that this depends, but I would appreciate just an indication from your experience (for example for a base container with Python runtime).

Many thanks in advance.

1

There are 1 best solutions below

0
On

A. As far as I'm aware it is only the memory your function will require during execution.

B. When your function isn't executing you aren't charged for any memory usage at all, if that's the reason you are asking this question. However, anything you have stored in a global variable will still be in memory during the next execution if the container is reused. The function doesn't continue running between executions, it is "frozen" and "thawed" as detailed in this Amazon blog post.

C. There is no such thing as an idle container in Lambda, so this part of your question doesn't really make sense. As I mentioned above, the container is only running when it is processing an invocation request, and is stopped and either destroyed or "frozen" once it completes.