# Lambda memory size: choosing the right setting

AWS configuration · Updated 17 November 2026

**Short answer:** Lambda memory can be set from 128 MB (the default) to 10,240 MB in 1 MB steps, and Lambda allocates CPU in proportion: at 1,769 MB a function has the equivalent of one full vCPU. Because cost is memory times duration, adding memory to a CPU- or network-bound function often makes it faster and no more expensive. Start around 512 to 1,024 MB for typical API handlers, then tune from measured Max Memory Used and duration rather than guessing.

## How memory, CPU and price relate

- **Range:** 128 MB to 10,240 MB for standard functions; default 128 MB.
- **CPU:** proportional to memory, one vCPU-equivalent at 1,769 MB and proportionally more above that. Below 1,769 MB a single-threaded function gets a fraction of a core.
- **Network bandwidth** per execution environment is 625 Mbps by default; for functions outside a VPC you can request an increase that then scales with memory, up to 3,000 Mbps at 10,240 MB.
- **Price** is per GB-second: doubling memory doubles the per-millisecond price, so it pays for itself only if duration falls by about half or more.

128 MB is right only for very small functions that route events. Anything that imports large SDKs, parses JSON of any size, or calls other services usually runs much faster with more.

## Recommended starting points

| Function type | Start at | Watch for |
|---|---|---|
| Event routing, small transforms | 128 to 256 MB | Duration spikes when payloads grow |
| Typical API handler (Node.js, Python) | 512 to 1,024 MB | Cold start time, p99 duration |
| Java, .NET, or heavy frameworks | 1,024 to 2,048 MB | Init duration; consider SnapStart for Java |
| CPU-bound (image processing, compression, crypto) | 1,769 MB or more | Duration falling as memory rises |
| Multi-threaded workloads | 3,538 MB+ (two or more vCPUs) | Only helps if the code uses threads |
| Large in-memory datasets | Peak heap + 20 to 30% | Max Memory Used close to the setting |

## Measure, then tune

Every invocation logs a REPORT line with `Memory Size` and `Max Memory Used`. Query them across many invocations:

```
filter @type = "REPORT"
| stats max(@maxMemoryUsed / 1000 / 1000) as maxUsedMB,
        avg(@duration) as avgMs, pct(@duration, 99) as p99Ms,
        max(@memorySize / 1000 / 1000) as configuredMB by bin(1h)
```

More on this in [the memory usage query](https://cloudconsole.dev/logs-insights/lambda-memory-usage). Then try two or three settings under realistic load and compare cost per invocation (memory GB x duration seconds). The open-source AWS Lambda Power Tuning state machine automates this comparison, and AWS Compute Optimizer gives memory recommendations for functions with enough history.

## Change it

```
aws lambda update-function-configuration --function-name image-resizer --memory-size 2048
aws lambda wait function-updated --function-name image-resizer
aws lambda get-function-configuration --function-name image-resizer --query '{memory:MemorySize,timeout:Timeout,tmp:EphemeralStorage.Size}'
```

**Console:** Configuration, General configuration, Edit, Memory. **CloudFormation:** `MemorySize` on `AWS::Lambda::Function` (SAM: `MemorySize` on the function or in `Globals`). **Terraform:** `memory_size` on `aws_lambda_function`.

Memory is separate from ephemeral storage (`/tmp`, 512 MB to 10,240 MB), which you set with `--ephemeral-storage Size=...`. If you publish versions, publish again so the alias uses the new setting.

## Symptoms of a wrong setting

| Symptom | Likely cause |
|---|---|
| `Max Memory Used` equals `Memory Size`, then `Runtime exited with error: signal: killed` | Too little memory; see [out of memory](https://cloudconsole.dev/errors/lambda-out-of-memory) |
| Long cold starts, slow first request | Too little CPU for initialisation; raise memory or trim dependencies |
| Duration falls little when memory doubles | I/O-bound; you're paying for unused CPU, step back down |
| Timeouts under load at low memory | CPU starvation; more memory often fixes it before a longer timeout does |

## Questions

### What is the default memory for a Lambda function?

128 MB. You can set any value from 128 MB to 10,240 MB in 1 MB increments.

### How much CPU does Lambda give per memory setting?

CPU is allocated in proportion to memory; at 1,769 MB a function gets the equivalent of one vCPU.

### Does increasing Lambda memory increase cost?

The price per millisecond rises with memory, but faster execution can offset it. For CPU-bound functions, more memory is often the same cost or cheaper overall.

## When this happens away from your desk

Memory problems show up as timeouts and out-of-memory errors under load. CloudConsole, a phone app for AWS, is being built to show Lambda duration and error alarms with the REPORT lines behind them on your phone.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Configure Lambda function memory](https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html)
- [Lambda quotas](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)

## Related

- [AWS Lambda limits and quotas](https://cloudconsole.dev/limits/lambda-limits)
- [Lambda memory usage with Logs Insights](https://cloudconsole.dev/logs-insights/lambda-memory-usage)
- [Runtime exited with error: signal: killed (Lambda out of memory)](https://cloudconsole.dev/errors/lambda-out-of-memory)
- [aws lambda update-function-configuration](https://cloudconsole.dev/cli/lambda-update-function-configuration)
- [Lambda reserved concurrency vs provisioned concurrency](https://cloudconsole.dev/config/lambda-reserved-vs-provisioned-concurrency)
- [CloudWatch alarm: Lambda Insights memory_utilization](https://cloudconsole.dev/alarms/lambda-insights-memory-utilization)

---

Source: https://cloudconsole.dev/config/lambda-memory-size

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
