How to Remediate Over-provisioned AWS Lambda Functions with Stratusphere™ FinOps

Optimize your AWS Lambda functions by uncovering over-provisioning with Stratusphere™ FinOps by StratusGrid. Ensure cost efficiency and performance today!

Need additional support?

Subscribe

Remediate Over-provisioned AWS Lambda Functions | Stratusphere™
7:34

AWS Lambda is a managed service that allows you to deploy individual software components, aka. “functions”, to the cloud. Lambda packages can actually contain many supporting functions and modules, but they always have a singular entrypoint. This service is colloquially known by terms including serverless, Functions as a Service (FaaS), cloud native programming, and others.

Lambda functions can be invoked directly as standalone components, or they can be orchestrated together through the use of other managed services, like AWS Step Functions state machines (aka. workflows). Lambda functions can also serve HTTP requests that are routed to them from the Amazon API Gateway service or from AWS Application Load Balancers. There are many other ways that Lambda functions can be used, in addition to these common use cases.

The logical separation of concerns that AWS Lambda provides allows developers to maintain, monitor, and scale various components separately from each other. This allows for safer, faster deployments and the creation of more cost effective and resilient architectures.

AWS Lambda Memory & Compute Power

When you create an AWS Lambda function, you can select how much memory (RAM) you want to allocate to it, ranging from 128 to 10,240 megabytes. Although you don’t have a separate control for CPU capacity, the amount of memory that you select actually determines how much CPU capacity is available to the function.

The AWS Lambda Insights integration with Amazon CloudWatch exposes metrics, such as memory_utilization, which indicates the maximum percentage of allocated memory that is used during invocations. You can use this metric data to help determine what the appropriate memory size allocation should be, for your AWS Lambda functions.

Identify Over-Provisioned Lambda Functions

Stratusphere™ FinOps is a SaaS solution from StratusGrid that collects and exposes this cost optimization data across all of your cloud accounts, and even across your company’s business structure. Onboarding with Stratusphere™ FinOps only takes a few minutes, at which point you can start gathering valuable, actionable data in your cloud environments.

What exactly does it mean for an AWS Lambda function to have an “over-provisioned” memory size? If you explore the AWS Trusted Advisor reference documentation for cost optimization, you’ll see that this rule is defined as a function’s memory configuration that may result in “paying for unused resources.” AWS Trusted Advisor provides a “recommended memory size” guidance for each of your over-provisioned functions.

Once you’re logged into the Stratusphere™ FinOps console, you can navigate to the Findings section, to see these actionable insights. You can narrow the scope of Findings to a specific company, and then filter the Service field to AWS Lambda. As you can see in the screenshot below, there are several over-provisioned Lambda functions that need optimization. While the potential monthly savings in this demo account is minimal, this can result in very large increases in costs for accounts with a high volume of Lambda invocations.

Stratuspheres Findings Dashboard

Now that you know which Lambda functions are flagged for optimization, it’s time to put that knowledge into action!

Risks & Other Considerations

There are several key points you’ll want to keep in mind, as you’re managing your AWS Lambda functions.

  • Although you can directly alter AWS Lambda function memory size, we strongly recommend managing your cloud resource configurations using an Infrastructure as Code (IaC) tool, such as AWS CloudFormation or Terraform CLI. To learn more about the benefits, check out this StratusGrid blog post.
  • Focus your efforts on high-volume Lambda functions, to get the most cost savings from the time you spend remediating Findings.
  • Keep in mind that reducing memory will reduce CPU performance as well. The reduction of size will result in varying performance results based on the amount of memory reduction, threading capabilities, and amount of time spent CPU bound.
    • This usually only matters for Lambdas being called synchronously and not for lambdas processing asynchronous queues.

Remediation

In order to remediate over-provisioned Lambda functions, you can simply update the memory configuration for the specified function, to a lower value. Each AWS resource, including Lambda functions, are identified by a unique Amazon Resource Name (ARN), which includes the account ID, region, and other related details.

  1. Login to the AWS Management Console
  2. Navigate to the AWS Lambda service
  3. Select the AWS region where your function exists
  4. Drill into your Lambda function, from the functions list
  5. Select the Configuration tab
  6. Click the Edit button
  7. Update the Memory field to the desired value
  8. Click the Save button

Updating the memory configuration for the specified function

That’s it! Your AWS Lambda function invocations will use the updated memory size.

Automated Remediation

In addition to the manual steps above, you can also automate the remediation of AWS Lambda functions, using the AWS APIs, or an Infrastructure as Code (IaC) tool. We’ll take a look at a couple of tools, the AWS CLI and AWS PowerShell module, to make these configuration changes directly against the AWS Lambda API.

AWS CLI Commands

The following AWS CLI command will change the configuration of an AWS Lambda function’s memory size.

aws lambda update-function-configuration --function-name stratusgrid01 --memory-size 505

AWS PowerShell Commands

You can use the AWS PowerShell module for Lambda to update the function configuration. First, install the Lambda module, and the call the command to change the memory size of your function. You can also specify the -Region parameter, to be explicit about where the Lambda function exists.

Install-Module -Name AWS.Tools.Lambda -Scope CurrentUser -Force

Update-LMFunctionConfiguration -MemorySize 403 -FunctionName stratusgrid01

Potential Errors

  • Error: Function not found
    • Resolution: This error may occur, when updating an AWS Lambda function’s configuration, if you specified the incorrect function name, or specified the incorrect AWS region where it resides.
  • Error: 1 validation error detected: Value '40000' at 'memorySize' failed to satisfy constraint: Member must have value less than or equal to 10240
    • Resolution: The maximum amount of memory that an AWS Lambda function can have is currently 10240 megabytes. Specifying a value larger than this will result in the constraint error above.

Optimize Your AWS Spend with Stratusphere™ FinOps by StratusGrid

You can reduce your AWS cloud monthly spend by implementing recommendations for AWS Lambda over-provisioned functions. The more volume your Lambda functions have, the greater cost savings you will see. Lambda functions with lower volume will generally not see a significant cost savings.

Are you interested in implementing cost optimization findings on a broad scale? StratusGrid’s engineering team can partner with you to identify cost savings opportunities with Stratusphere™ FinOps, and automate the remediation of many findings.

For more information, check out the references below.

Contact us today to get started!

See Stratusphere™ FinOps in Action:

 

BONUS: Download Your FinOps Guide to Effective Cloud Cost Optimization Here ⤵️

FinOps-Guide-Downloadable (2)

Similar posts