← AWS Lambda memory size calculator
How the AWS Lambda calculator works
This page walks through how the Lambda calculator turns your usage data into a function's
MemorySize. It starts from the peak side of the shared sizing model;
this page covers what happens after that. Statements backed by AWS's documentation end with an
AWS docs link to it. Choices the documentation doesn't make for us
are explained and marked Assumption, which links to its row
in the table of all of them.
01 What MemorySize does
- It is the memory available to the function at runtime, from 128 MB to 10,240 MB in 1 MB steps. AWS docs
- Lambda allocates CPU in proportion to it: at 1,769 MB a function has the equivalent of one vCPU. AWS docs
- The duration cost depends on it too: the price per millisecond grows with the memory allocated. AWS pricing
There is no separate reservation and limit, and running out of memory fails the invocation, so the calculator
sizes MemorySize from the peak alone. The average you enter doesn't change the result.
Cloud Run and Azure Functions also size from the peak alone: see the Cloud Run guide and the Azure Functions guide.
02 From peak usage to MemorySize
memory = peak × (1 + limit margin) in MiB
MemorySize = memory × 1,048,576 ÷ 1,000,000 in MB, rounded up to a whole MB
kept within 128–10,240 MB
The limit margin comes from the sensitivity, workload type and environment you choose; the sizing model explains it, and it's an assumption too.
AWS's own Logs Insights queries turn Lambda's memory figures into MB by dividing the bytes by 1000 twice, so Lambda's MB are decimal megabytes: 1 MiB is 1.048576 MB. AWS docs The documentation never defines the unit outright, so this is how we read it. Assumption
Worked example
Peak 630 MiB, generic workload, medium sensitivity, production:
| memory | 630 MiB × 1.30 | 819 MiB |
|---|---|---|
| in MB | 819 × 1.048576 = 858.8 | 859 MB |
| CPU | 859 ÷ 1,769 | ≈ 0.49 vCPU |
A small function, peaking at 60 MiB, lands below Lambda's minimum and is raised to it:
| in MB | 60 MiB × 1.30 = 78 MiB = 81.8 MB, below 128 | 128 MB |
|---|
03 Memory, CPU and cost
Because CPU comes with memory, AWS calls memory the principal lever for a function's performance: a CPU-, network- or memory-bound function can run much faster with more. AWS suggests watching memory and duration in CloudWatch, trying the open-source Lambda Power Tuning tool, or accepting Compute Optimizer's recommendations. AWS docs
This calculator only answers the memory question: how much the function needs so it doesn't run out. It doesn't measure duration, so it can't tell whether more memory would make a function faster or cheaper; run Power Tuning for that. Assumption
04 What the calculator writes
{ "MemorySize": 859 }
aws lambda update-function-configuration --function-name <function> --memory-size 859
MemorySize is the property name in AWS SAM templates, and
update-function-configuration with --function-name and --memory-size is the
CLI command AWS documents for changing it.
AWS docs
05 Every warning, and why
| Message about | Shown when | Basis |
|---|---|---|
| Outside Lambda's range warning | The result is below 128 MB or above 10,240 MB | Lambda only accepts that range. AWS docs |
| Peak below average error | The peak you entered is lower than the average | Impossible with real samples; it usually means two different series. See the sizing model. |
06 What to paste
fields @maxMemoryUsed
| filter @type = "REPORT"
-
Run it in CloudWatch Logs Insights on the function's log group. Lambda's
REPORTlines, one per invocation, carry the discovered fields@maxMemoryUsedand@memorySize. AWS docs AWS's sample query divides them by 1000 twice to get MB, so they are bytes, and the calculator reads them as such. AWS docs - Each value is the most one invocation used, so the calculator's "average" is the average of those maximums and its peak the largest of them. Only the peak sets the result. Assumption
07 All assumptions in one place
Besides the margins of the shared sizing model:
Our default: a value we chose. Our reading: how we read documentation that isn't explicit. About your setup: something we take for granted about your data or cluster.
| Assumption | Kind | Why | If it doesn't hold |
|---|---|---|---|
| Lambda's MB are decimal (1,000,000 bytes) ↩ | Our reading | AWS's sample queries divide by 1000 twice | If they were MiB, the result would be about 5% larger than needed. |
| Size for memory use only, not for speed or cost ↩ | Our default | The calculator sees memory, not duration | A CPU-bound function may be faster or cheaper with more memory; Power Tuning finds out. |
| Each sample is one invocation's maximum ↩ | About your setup | That's what @maxMemoryUsed holds | Pasting other figures, such as averages, hides the peak and gives too small a result. |
Values you can change
The calculator’s Advanced: margins and defaults section, closed by default, lets you replace these values when your setup differs. Each field’s “?” says how it moves the result; a value outside the range is used at its nearest end, and “Reset to defaults” puts them all back.
| Value | Default | Range | Where the default comes from |
|---|---|---|---|
| Limit margin | from the profile | 0–200% | MemoryLimit’s default, from sensitivity, workload type and environment (sizing model); sizes MemorySize |
08 References
- Configure Lambda function memory — the range, CPU per MB, how to choose, the CLI command.
- AWS Lambda pricing — duration cost depends on memory.
- CloudWatch Logs Insights sample queries — the Lambda memory query and its MB conversion.
- Discovered fields —
@maxMemoryUsedand@memorySize. - AWS Lambda Power Tuning — measuring speed and cost at different memory sizes.