VOOZH about

URL: https://thenewstack.io/reduce-kubernetes-costs-using-autoscaling-mechanisms/

⇱ Reduce Kubernetes Costs Using Autoscaling Mechanisms - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2021-05-31 03:00:23
Reduce Kubernetes Costs Using Autoscaling Mechanisms
contributed,sponsor-cast-ai,sponsored,sponsored-post-contributed,
Containers / Kubernetes

Reduce Kubernetes Costs Using Autoscaling Mechanisms

Kubernetes comes with three built-in autoscaling mechanisms. The tighter they’re configured, the lower the costs of running your application.
May 31st, 2021 3:00am by Laurent Gil
👁 Featued image for: Reduce Kubernetes Costs Using Autoscaling Mechanisms
Featured image via Pixabay.
cast.ai sponsored this post.
Laurent Gil
Laurent is co-founder and CPO at CAST AI.

Technically, containerization should be more cost-effective by default, but Kubernetes is riddled with expensive cost traps that may cause you to go over your budget. Fortunately, you have a few tactics to keep cloud costs at bay, and autoscaling is one of them. Kubernetes comes with three built-in autoscaling mechanisms to help you do that. The tighter they’re configured, the lower the costs of running your application.

Keep on reading to learn how these autoscaling mechanisms help to reduce your AWS bill for Kubernetes.

1. Horizontal Pod Autoscaler (HPA)

Many applications experience fluctuating usage, which means that adding or removing pod replicas is in your best interest. This is where Horizontal Pod Autoscaler (HPA) helps by doing that automatically.

When to Use HPA?

It works great for scaling stateless applications, but is also a good match for stateful sets. To get the highest cost savings for workloads where demand changes regularly, use HPA together with cluster autoscaling. This will reduce the number of active nodes when the number of pods decreases.

How Does HPA Work?

HPA monitors pods to understand whether the number of pod replicas needs to change. To determine this, it takes the mean of a per-pod metric value and checks whether removing or adding replicas would bring that value closer to the target.

For example, if your deployment’s target CPU utilization is 50% and right now you have five pods running there, your mean CPU utilization is 75%. To bring the pod average closer to your target, the HPA controller will add three replicas.

HPA Best Practices

  • Provide HPA with a source of per-pod resource metrics: You need to install metrics-server in your Kubernetes cluster.
  • Configure values for every container: HPA makes scaling decisions based on the observed CPU utilization values of pods, a percentage of resource requests from individual pods. If you fail to include values for some containers, the calculations will be inaccurate and lead to poor scaling decisions. So configure these values for every single container in every pod part of the controller scaled by HPA.
  • Use custom metrics: Another source of HPA’s scaling decisions is custom metrics. HPA supports two types of custom metrics: pod metrics and object metrics. Make sure to use the right target type. You can also use external metrics from third-party monitoring systems. (Note that securing an external metrics API might be more challenging.)

👁 Image

2. Vertical Pod Autoscaler (VPA)

This autoscaling mechanism increases and reduces the CPU and memory resource requests of pod containers to align the allocated cluster resources with actual usage. VPA also needs access to the Kubernetes metrics server since it replaces only pods that are managed by a replication controller.

Tip: Use VPA and HPA at the same time if your HPA configuration doesn’t use CPU or memory to set its scaling targets.

When to Use VPA?

A workload might experience high utilization at one point or another, but increasing its request limits permanently is a bad idea. You risk wasting CPU or memory resources and limiting the nodes running them. Spreading a workload across multiple application instances is tricky; this is where Vertical Pod Autoscaler helps.

How Does VPA Work?

VPA deployment consists of three components:

  • Recommender: Monitors resource utilization and calculates target values
  • Updater: Checks whether pods resource limits require updating
  • Admission Controller: Overwrites the resource requests of pods when they’re created

Since Kubernetes doesn’t allow making changes in the resource limits of running pods, VPA first terminates pods using outdated limits and then injects the updated values to the new pod specification.

VPA Best Practices

  • Avoid using VPA with Kubernetes versions older than 1.11 or use version 0.3 of VPA.
  • Run VPA with updateMode: “Off” to understand the resource usage of the pods you’re looking to autoscale. This will give you the recommended CPU and memory requests, which are a great foundation for later adjustments.
  • If a workload experiences regular spikes of high and low usage, VPA might be too aggressive because it might keep on replacing pods over and over again. HPA works better in such scenarios.
CAST AI is a cloud optimization platform that reduces cloud costs 50% to 90%, optimizes DevOps, and automates disaster recovery via multicloud. Our AI-driven optimization engine delivers a cost-efficient, high-performing, and resilient infrastructure for every Kubernetes workload.
Learn More
The latest from cast.ai

3. Cluster Autoscaler

Cluster Autoscaler alters the number of nodes in a cluster on supported platforms. Since the autoscaler controller works on the infrastructure level, it needs permissions to add and delete infrastructures, and you should manage these credentials securely (for example, following the principle of least privilege).

When to Use Cluster Autoscaler?

This autoscaling mechanism works well if you’re looking to optimize costs by dynamically scaling the number of nodes to fit the current cluster utilization. It’s a great tool for workloads designed to scale and meet dynamic demand.

How Does Cluster Autoscaler Work?

It checks for unschedulable pods and then calculates whether it’s possible to consolidate all of the pods deployed currently to run them on a smaller number of nodes. If Cluster Autoscaler identifies a node with pods that can be rescheduled to other nodes in the cluster, it evicts them and removes the spare node.

Cluster Autoscaler Best Practices

  • When deploying Cluster Autoscaler, use it with the recommended Kubernetes version. (Here’s a handy compatibility list).
  • Check whether cluster nodes have the same CPU and memory capacity: Cluster Autoscaler won’t work otherwise because it assumes that every node in the group has the same capacity.
  • Make sure that all the pods scheduled to run in a node or instance group for autoscaling have specified resource requests.

Why Automating Kubernetes Scaling Is a Good Idea

These native autoscaling mechanisms are incredibly valuable for keeping cloud costs at bay, but they require significant manual configuration:

  • Preventing HPA and VPA clashes: You need to check whether your HPA and VPA policies end up clashing. Keep a close eye on costs to prevent them from getting out of hand.
  • Diversified allocation and spot instances together: Adopting a diversified allocation strategy and using spot instances are two powerful cost-saving activities that are hard to coordinate manually.
  • Balancing all three mechanisms: You need a balanced combination of all three mechanisms to ensure that workloads support peak load and keep costs to the minimum during times of lower demand.

You probably see why automating this aspect of running Kubernetes clusters is a smart move. Just to give you an example, tools such as CAST AI can add new nodes automatically for the duration of the increased demand and then scale down immediately to reduce waste.

Here’s an example of what an automated autoscaling flow looks like:

👁 Image

  1. When the application experiences a surge of traffic, Horizontal Pod Autoscaler creates new pods. But there’s no place to run them, so we need 15.5 new CPU cores.
  2. CAST AI automatically adds a new 16-core node within two minutes.
  3. But look what happens at 15:45: Even more traffic hits the application.
  4. To make it work, CAST AI adds an extra eight-core node within one minute.
  5. Once the traffic is gone, the platform instantly retires two nodes to help avoid resource waste. CAST AI chose spot instances for the additional work at a 70% discount to drive costs down further.

If you run your Kubernetes clusters on Amazon Web ServicesEKS, here’s something to help you take the first step: Generate a free Available Savings report and start optimizing your cloud costs.

CAST AI is a cloud optimization platform that reduces cloud costs 50% to 90%, optimizes DevOps, and automates disaster recovery via multicloud. Our AI-driven optimization engine delivers a cost-efficient, high-performing, and resilient infrastructure for every Kubernetes workload.
Learn More
The latest from cast.ai
TRENDING STORIES
Laurent Gil is cofounder and president of Cast AI, overseeing product and business development. Previously, he co-founded Zenedge, where he served as chief product and business officer before its acquisition by Oracle in 2018. He was also CEO and cofounder...
Read more from Laurent Gil
cast.ai sponsored this post.
SHARE THIS STORY
TRENDING STORIES
Amazon Cloud is a sponsor of The New Stack.
TNS owner Insight Partners is an investor in: Pragma.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.