How to Remediate Lambda Functions with Excessive Timeouts in Stratusphere™ FinOps
Discover how to tackle excessive timeouts in AWS Lambda. Learn strategies to optimize your functions in Stratusphere™ FinOps and boost your cloud...
Optimize your AWS Lambda functions by uncovering over-provisioning with Stratusphere™ FinOps by StratusGrid. Ensure cost efficiency and performance today!
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.
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.
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.
Now that you know which Lambda functions are flagged for optimization, it’s time to put that knowledge into action!
There are several key points you’ll want to keep in mind, as you’re managing your AWS Lambda functions.
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.
That’s it! Your AWS Lambda function invocations will use the updated memory size.
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.
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
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
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!
BONUS: Download Your FinOps Guide to Effective Cloud Cost Optimization Here ⤵️
Discover how to tackle excessive timeouts in AWS Lambda. Learn strategies to optimize your functions in Stratusphere™ FinOps and boost your cloud...
Discover how to efficiently backfill Cost and Usage Reports (CUR) from AWS into StratusGrid's cost optimization dashboard Stratusphere™ FinOps in our...
Streamline your AWS costs: eliminate idle load balancers with Stratusphere™ FinOps. Discover how to remediate underutilized AWS Elastic Load...