Reputation: 7414
I am running an aspnetcore 2.1 Lambda with 128mb of ram allocated to it. When I run the Lambda it executes for 15 seconds (my timeout period) and then fails with a Task Timeout
. It reports out that I consumed 56mb of memory out of the 128mb of ram allocated for it.
If I bump the ram up to 192 or 256mb it runs without issue in under 1 second. It reports out that the same amount of ram was consumed, but now with a higher ceiling. If I'm consuming less than 50% of the ram I've allocated, why am I seeing executions stall?
Is the memory allocation for the entire container and not just the Lambda executing within it? I had assumed that the ram I specify is what would be allocated for my process to run under within the container. Is that not the case? If this memory allocation is shared with the other resources within the container does Amazon publish the memory usage of their containers so I can estimate better?
Upvotes: 2
Views: 1652
Reputation: 269284
From Configuring Lambda Functions - AWS Lambda:
You only specify the amount of memory you want to allocate for your Lambda function. AWS Lambda allocates CPU power proportional to the memory by using the same ratio as a general purpose Amazon EC2 instance type, such as an M3 type. For example, if you allocate 256 MB memory, your Lambda function will receive twice the CPU share than if you allocated only 128 MB.
So, your functions ran faster because, in providing them with extra memory, you were also providing additional CPU.
All allocated RAM and CPU is assigned only to your Lambda function. The function will not be shared nor impacted by any other functions, containers, users or networks.
See also: How does proportional CPU allocation work with AWS Lambda?
Upvotes: 4