Getting A Handle On Spiralling Aws Lambda Cost In ~15 Sec

AWS Lambda function might look low-priced while getting started. Even though developers can limit its max memory size and max function execution time, there are chances of costs spiraling out of control due to several reasons. It could be because of a DDoS attack, excess memory allocation to each function, or a bug in the code that accidentally invokes a function innumerable times!

In this post, we walk you through ways to get a handle on the cost of Lambda functions, and how a visual console can help you get clarity in ~15 seconds (Jump to Point#4 to watch it in action now!).

Factors that Affect AWS Lambda Cost:

At the top level, it looks like AWS bills you only for the time your Lambda functions are running.In actuality, it depends on:

– The number of executions/requests

– The time range for which a function is running (rounded up to the nearest 100 ms)

– The memory size of the function

Example: if a function uses 512 MB and is called 5 million times in a month (lasting one second for each invocation), the monthly cost for this Lambda alone would be  $36.8072.  Consider the number of dollars you would spend on all the functions put together!

Ideally, you have to keep a healthy balance between memory allocation, number of invocations and run time of the function to avoid the risk of overpaying. Monitoring lambda functions for optimality must be a part of your regular audits. Otherwise, the spend might reach up to hundreds of dollars.

Here are a few ways to monitor these functions for cost optimization:

#1 The Good Old Manual Approach:

(Takes minutes to hours depending on the number of functions.)

Every time a Lambda executes, a record prints:

Duration: 1000 ms Billed Duration: 500 ms Memory Size: 512 MB Max Memory Used: 25 MB

The above record clearly shows that the function is using just 25 MB out of 512 MB. In this scenario, a function with 128 MB of memory works fine too as well as save hundreds of dollars per month. However, if you allocate much lesser, the function might drop before execution.

On that account, monitor Lambda records regularly. The challenge, however, with this approach is you have to spend a lot of time and effort in monitoring each function. More the functions, more amount of time and effort you have to invest in knowing their performance.

That’s why several cloud engineers across the globe use AWS calculator or test the function before launching, with different memory allocations, execution time and run time and then calculate the cost.

#2  The Cost Explorer Approach:

(Takes few minutes, if all the Lambda functions are appropriately tagged.)

Using AWS Cost Explorer, you can closely monitor the pricing for the week, month, or quarter, slicing and dicing it further by Service, Region, AZ, Usage Type, Tag name, etc.

AWS Lambda functions Cost for RabbitMQ

Cost of Lambda function that triggers RabbitMQ

Despite the cost details, the AWS console does not provide the visibility into actual problem area. You can just figure out whether the Lambda function costs have spiralled out of control, when an issue occurs.

If you have tagged your Lambdas properly, you can check out each of these tagged function’s pricing for the week in the console and discover the culprit function to take further action. If you have not, it’s next to impossible to find that culprit function. So several developers use CloudWatch Alarms to get a notification when a function exceeds the set limits.

#3  The Third-Party Tools Approach:

(Takes minutes to hours depending on the number of functions)

There are several third party tools available in the market, like this cool tool on GitHub that calculates AWS Lambda costs in near real-time. Even with such tools, you have to key in all the details to get cost details manually. You have to sieve through data to make sense of the entire picture.  

#4  Using a Visual Console:

(Takes ~ 15 seconds, irrespective of whether the functions are tagged or not!)

One of the novel ways to monitor Lambda cost by memory, runtime , execution time, code size, subnet, and more is to use a visual console.  

Like TotalCloud’s state-of-the-art interface featuring built-in filters. These filters help group resources by several parameters like memory utilization, runtime, execution, etc. at multiple levels. The console’s Cost Analyzer analyzes spend on top of these grouped resources, in 3D space. Above all, the interface helps you get a viewable context of Lambda usage and get a handle on spending, in real-time, in just a few seconds. Watch the video below to know more.

The Wrap up:

If you observe the table below, the time and effort it takes to monitor the performance and cost of Lambda:

– The Manual Way: minutes to hours depending on the number of functions

– The Cost Explorer Way: few minutes, if and only if you tag all the Lambda functions properly

– The TotalCloud Way: ~ 15 seconds, irrespective of whether you tag the functions or not! Plus, you get the cost and performance perspective at a glance, on a single pane of glass.

AWS Lambda function’s pay-per-use billing model, turning on only during execution definitely saves on computing resources and costs. That said, it is equally important to keep a close watch on sub-optimal functions, while also track its cost, in real-time.

Getting A Handle On Spiralling Aws Lambda Cost In ~15 Sec

Smart Scheduling at your fingertips

Go from simple to smart, real-time AWS resource scheduling to save cost and increase team productivity.

Learn More
More Posts

You Might Also Like

Cloud Computing
How To Migrate To Azure Faster?
Migrating from on premise data centers to a cloud provider is always considered a difficult endeavor. From the cost, to the planning and resource allocation, plenty of preliminary work is gone to setting up a cloud infrastructure. Which is why, Microsoft Azure’s new program stands to benefit many organizations still on the fence about migrating to the cloud.
July 21, 2021
Cloud Computing
Everything You Need To Know About Kubernetes Scheduler
When creating a Kubernetes cluster, scheduling the pod to an available node is an important component of the process. This component works under specific rules and technicalities that I’d like to explore in this article...
September 23, 2020
Cloud Computing
20 Cloud Influencers You Should Be Following in 2020
It’s important to follow the right individuals so that you remain on the loop and always find yourself learning things that you were unaware of. These thought leaders and influencers can only be the avenues by which you meet other interesting technologists.
September 23, 2020
Cloud Automation
New In: No-code cloud management workflows for Azure, VMware & Private Cloud (in addition to AWS)
At TotalCloud, we’ve been enabling workflow-based cloud management for AWS to make it intuitive, accelerated, and no-code. Instead of programming cloud management use cases or depending on siloed solutions, we built out a platform that gives you building blocks to assemble any cloud management solution. 
September 4, 2020
Cloud Computing
List of Essential Kubernetes Tools
Kubernetes is a Container-as-a-Service with tons of unique tools to choose from. External tools play a role in integrating with different systems or maintaining control over the clusters you deploy. Manual health checks and troubleshooting is not ideal to keep a system in full health.This list of tools will provide ample support to your containers and have enough configuration to leave management flexible...
August 12, 2020
AWS Use Case Files
TotalCloud Inventory Actions: Giving a new meaning to Cloud Inventory
Learn how the TotalCloud Inventory Dashboard can become equivalent to your cloud provider’s SDK. Carry out any action on any discovered resource with Inventory Actions.
July 30, 2020