By on August 31, 2021

8 Cloud Cost Optimization Tactics for Kubernetes


← Back to Blog Home

If you’ve ever gotten sticker shock after receiving a surprisingly large cloud bill, this might have been your reaction…

kitten-meme

I think we’ve all been there. While the cloud makes flexible scaling possible, it has also introduced many new services one can use, resulting in increased cloud costs.

In this article, I’ll go over the eight ways you can reduce your Kubernetes cloud costs. I use Amazon Web Services (AWS) as an example, but the lessons can also apply to other cloud providers.

 

For more helpful Kubernetes content, visit Kong’s blog.

1. Define Your Requirements

You should only order what your workload needs across your compute dimensions, from CPU account and architecture to memory storage and network. An affordable instance might look tempting, but what happens if you start running a memory-intensive application and you end up with the performance issue affecting your brand or customers? It’s not a good place to be. Pay attention when choosing between CPU and GPU instances.

2. Choose the Right Instance Types

AWS offers more than 150 different instance types. Picking the right type can go quite a long way in helping with your cloud cost optimization. Cloud providers offer many different instance types, matching various use cases with different CPU combinations, memory storage and networking capacity. Scale your resources properly. 

Cloud providers roll out different computers for their virtual machines (VMs), and the chips in those computers have different performance characteristics. You might pick an instance type with more performance than you need without even knowing. The best way to verify a few capabilities is by benchmarking. Try dropping the same workload on each machine type and checking its performance from there.

3. Verify Storage Transfer Limitations

It’s worth your time to work on data storage as part of your cloud cost optimization efforts. Each application comes with unique storage needs. Make sure that the VM you pick can maintain the storage you need throughout your workflow. Avoid expensive drive options like premium solid-state drive (SSD) unless you plan to use them to the fullest.

4. Check If Your Workload is Spot-Ready

Spot instances are a great way to save on your Kubernetes bill. Before jumping into the spot space, you need to decide how to build your framework, use its instances and implement it. Here are a few questions that you should think about before going with spot instances: 

  • How much time does your workload need to finish the job? 
  • Is it mission and time-critical? 
  • Can you handle interruptions? 
  • Is it tightly coupled between instance nodes? 
  • What tools are you going to use to move your workload when a cloud provider pulls the plug? 

These are just a few beginning questions that you need to answer before jumping into the spot world.


For more on API Automation, check out
Kong’s Destination: Automation event recordings.

5. Cherry-Pick Your Spot Instances

After you pick your instance, check its interruption frequency at the rate with which the instance claimed capacity during the trailing month. The AWS instance advisor covers a wide range of intervals, so don’t shy away from using spot instances for more important work if you know what you’re doing. 

AWS offers the type of spot that gives you an uninterrupted time guarantee for up to six hours in hourly increments, and you just pay a little more for it and still achieve a discount on the on-demand pricing.

6. Bid Your Price on Spot

Once you find the right instance, it’s then a good time to set the maximum price you are ready to pay for it. The instance will only run on the marketplace price below or equal to your bid. Here’s a rule of thumb. Set the maximum price to the one that equals the on-demand price. Otherwise, you risk getting your workload interrupted once the price goes higher than what you have set. 

To boost your chances of snatching spot instances, you can set up groups of spot instances called, in AWS cloud, spot fees and request multiple instant types simultaneously. You’ll be paying the maximum price per hour for the entire fleet rather than the specific spot pool. And it requires a lot of work, but cloud cost optimization will happen even though it takes a bit of time to manage it.

7. Use Mixed Instances

Mixed instances are specific to Kubernetes. Only a mixed instance strategy gets you great availability and performance at a reasonable cloud cost. Pick different instance types. Some are cheaper and good enough but might not be suitable for high throughput and low latency workload. Depending on your workload, you can often pick the cheapest machine and make it work. Or you could have a smaller number of machines with higher specs. 

Doing so could help slash your Kubernetes bill because each node requires Kubernetes to be already installed. And it always adds a little overhead, but mixed instances do present some scaling challenges. In a mixed instance scenario, each instance uses different types of features. While you can scale up the instance in your order scaling groups using CPU and network utilization metrics, you’ll get inconsistent metrics. But then cluster or a scalar helps here by allowing you to mix instanced types in the node group.

8. Make Regions Work for You

Instances spanning across several regions increase your availability. So it’s recommended, for example, by AWS cloud to configure multiple node groups, scope each of them to a single region and then enable that to balance a similar node group’s feature. 

If you create only one group, you can scope that node group standard across multiple regions.

CNCF Projects to Help With Cloud Cost Optimization

The Cloud Native Computing Foundation (CNCF), which is home to Kubernetes, has many projects that could be helpful along your cloud cost optimization journey.

Automation-Driven Cloud Cost Optimization

One of the best approaches to cloud cost optimization is using an automated solution. Then you can get full benefits from all the things I mentioned above without too much work on your part. For this, I recommend CAST AI. Check out the demo in the below recording from my Destination: Automation below.

 

For more on API Automation, check out Kong’s Destination: Automation event recordings.

Kong Summit 2021

Tags:

Share Post: