Serverless computing adoption soared in 2022, according to the 2022 CNCF Cloud Native Survey. With this growing popularity comes the potential risk of increasing cloud spending unless enterprises take a proactive approach to serverless costs through strategy, optimization, and monitoring.
Here are some tips on how to prepare your development team to approach serverless cloud costs proactively and not reactively after your CFO opens the first cloud bill after your serverless project goes live.
Learn the pricing models of the major cloud service providers
Choosing the right serverless computing solution starts with your cloud service provider (CSP). Even then, serverless will take you to a new pricing model that your team needs to learn. Each of the major CSPs offers serverless computing with its own pricing model. For example, Amazon Web Services announced tiered pricing for AWS Lambda, their serverless compute offering. When news like that drops, it’s often a signal to refresh yourself on serverless pricing models.
Institute efficient coding practices on your serverless projects
Introducing serverless computing into your cloud technology stack is an excellent time to review your organization’s coding practices. Instituting efficient coding practices on your serverless development projects is one of the first and most important steps you can take as part of your serverless computing cost optimization initiatives. Coding practices that help lower serverless computing costs include:
- Minimizing the size of the code
- Using optimal libraries
- Optimizing function performance
Right-size functions starting at the design phase
Overprovisioning memory and CPU allocation are two culprits often found behind serverless computing cost overruns. When you execute a serverless function in your cloud application, your CSP allocates resources according to the function’s configuration. Then when billing time comes around, your CSP bases your billing on the amount of resources your application consumes.
It makes good business sense to spend the extra time during the design phase to determine the appropriate amount of resources that each serverless function requires, so you’re minimizing costs.
Use compute only when necessary
Train your cloud developers to use compute only when necessary, advises CloudZero. They give the example of using step functions to call APIs instead of Lambda functions, meaning you only pay for the step functions.
Set and track relevant serverless cost KPIs
The major CSPs and cloud management platforms include key performance indicator (KPI) monitoring dashboards of one form or another. You can also use observability tools, such as Datadog, for KPI monitoring. Monitoring your serverless KPIs should figure prominently in your project and deployment plans.
Core to managing and tracking serverless costs is embracing KPIs including:
- Cost per execution. This metric reflects the average cost of executing a single function one time. You calculate cost per execution by dividing the total cost by the number of function executions. Tracking this KPI is essential because it identifies which functions are the most expensive to run and require optimization to reduce your cloud costs.
- Function duration. The duration of function execution is an important KPI to track, as longer function execution times mean higher costs. Analyzing this metric helps identify which functions take too long to execute and require optimization to achieve further cost savings.
- Idle time. This may seem like an innocuous KPI to track, but your CSP still bills you when a serverless function is running but not performing any useful work, such as when waiting for input or output. Reducing idle time in your serverless functions is another crucial tactic for optimizing resource utilization while lowering your cloud spend.
Memory usage, CPU usage, number of invocations, and error rate also contribute to higher cloud costs, and you should monitor them accordingly. Factor in time to analyze for trends and make it a point to discuss serverless cloud costs in your project reporting because it can help everybody learn how to make more efficient use of the cloud.
Play full court when it comes to cost monitoring and alerts
Most likely, your organization’s cloud FinOps expertise and practices are still in growth mode. If so, adding serverless computing to your technology stack can raise a new specter of cloud spending concerns, making a full-court approach to managing serverless cloud costs a must. Here are some tips to make that happen:
- Support the learning curve of your cloud team by doubling down on the analysis of your billing and usage reports, at least during your pilot serverless computing projects.
- Automate cost management practices when feasible but don’t treat automation as a one-time, “set it and forget it” event. Cost management of your first serverless projects is bound to be a learning process for developers and FinOps team members alike. Embrace iterative improvement.
- Implement cost monitoring and alerts over your serverless computing projects early in the project lifecycle. You can use tools such as AWS Cost Explorer to monitor your serverless costs directly, and set alerts for when your serverless costs exceed budget. Expect to spend some time iterating these alerts to ensure that your teams are made aware of unexpected usage spikes or application inefficiencies that drive up costs unexpectedly.
Consider using a specialized serverless cost optimization tool
Consider upgrading to a serverless cost optimization tool as part of your overall commitment to serverless computing. A new class of cloud optimization tools focuses on the optimization of serverless costs. Examples include Epsagon, IOpipe, and Lumigo, which use machine learning algorithms to analyze your usage patterns and recommend further optimizations your developers can make to your serverless computing application to help reduce costs.
The rollout of serverless computing can add another level of complexity to your overall cloud cost optimization efforts. However, it doesn’t have to pose a cost management conundrum or shock the CFO with a skyrocketing cloud bill. If your teams are proactive and put the proper tools and processes in place, you can introduce serverless cost control into your cloud cost optimization program as smoothly as serverless compute slips into your cloud tech stack.
Such proactivity will ensure the introduction of serverless into your cloud tech stack sets back your cloud cost optimization initiatives.
Copyright © 2023 IDG Communications, Inc.
Originally posted on April 18, 2023 @ 9:18 am