> ## Documentation Index
> Fetch the complete documentation index at: https://help.nops.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Rightsize Lambda Function

> Lower the memory of Lambda functions that use less than they are configured with.

Lambda bills each invocation by its configured memory and duration. AWS Compute Optimizer looks at how much memory a function actually uses and how long it runs, and recommends a memory size that costs less without slowing the function down much. nOps imports these recommendations daily through AWS Cost Optimization Hub and shows the estimated monthly saving.

| | |
| - | - |
| **Cloud** | AWS |
| **Category** | Serverless |
| **Service** | AWS Lambda |
| **Action** | Rightsize |
| **Effort** | Low |
| **Restart needed** | No |
| **Can be rolled back** | Yes |
| **Analysis window** | Last 14 days |
| **Source** | AWS Compute Optimizer |

## Why it matters

Memory is often set high once and never revisited. For functions that run millions of times, a smaller memory setting saves money on every invocation.

## How nOps finds it

This recommendation comes from AWS Compute Optimizer, not from nOps. Compute Optimizer analyzes the function's memory use and duration over its lookback period and recommends a memory size and an estimated saving. nOps imports the highest-saving recommendation AWS gives for each function.

## Before you start

AWS Compute Optimizer enabled for the account, and permission to update the function configuration (`lambda:UpdateFunctionConfiguration`).

## How to implement

1. Review the recommended memory size and the projected duration.
2. Test the function at the new memory size, ideally on a test alias or version, and check duration and errors.
3. Change it: **Lambda → Functions → Configuration → General configuration → Edit → Memory**, or `aws lambda update-function-configuration --function-name NAME --memory-size MB`.
4. Update the memory in Terraform, CloudFormation or SAM so a later deployment does not change it back.

## Risks and considerations

* Lambda allocates CPU in proportion to memory, so less memory can mean longer runs. Watch duration and timeouts after the change.
* Functions with spiky or seasonal input may need more memory than the lookback period showed.
* To roll back, set the memory back to its previous value.

## FAQs

> [accordion] Why doesn't every function get a recommendation?
>
> Compute Optimizer only analyzes functions with enough invocations in its lookback period.

## Related

* [Switch Lambda Function to Arm64](https://help.nops.io/inform/supported-recommendations/switch-lambda-function-to-arm64)
* [Reduce Lambda Provisioned Concurrency](https://help.nops.io/inform/supported-recommendations/reduce-lambda-provisioned-concurrency)
* [Supported recommendations](https://help.nops.io/inform/supported-recommendations.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.