Case study

CategoryArticles
Updated: 7/9/2024Published: 4/8/2024

Optimizing Kubernetes Workloads on AWS EKS for Cost Efficiency

Kubernetes has become the ubiquitous standard for container orchestration and has revolutionized the way we deploy and manage containerized applications. Despite its benefits of scalability, flexibility, and ease of management, for organizations that run their workloads on Kubernetes, cloud services cost remains a critical concern. One effective strategy for optimizing the costs of Amazon Elastic Kubernetes Service (Amazon EKS) workloads is leveraging Spot Instances.

In this article, we'll explore how to optimize Kubernetes workloads on AWS EKS for cost efficiency in general and using spot instances.

Understanding AWS EKS pricing

As a partially managed service, AWS EKS charges a flat fee of $0.10 per hour for each EKS cluster created, which covers the management of the Kubernetes control plane. This fee is constant regardless of the number of nodes or the size of the cluster, making it predictable and straightforward.

Amazon EKS pricing is closely tied to the costs of the underlying infrastructure, which can be built using EC2 instances or Fargate. Therefore, those looking to optimize EKS costs should primarily focus on this area. You can follow the next list of recommendations or proceed directly to the next part of this article, which describes how we used Spot EC2 instances.

  • Utilize Reserved Instances for production: Reserved Instances provide significant cost savings for predictable and steady-state workloads by offering up to 50% discount compared to On-Demand pricing. Committing to a one-year or three-year term can result in substantial savings for production environments.

  • Use Auto Scaling groups: Implement Auto Scaling Groups to automatically adjust the number of EC2 instances based on demand. This ensures that you only pay for the capacity you need, helping to minimize costs during low-demand periods.

  • Select appropriate instance types: Choose the right instance types that match your workload requirements in terms of CPU and memory. This avoids over-provisioning and ensures cost-efficiency.

  • Leverage Spot instances: This is described in the next section of this blog post.

Understanding Spot Instances

Spot Instances are spare AWS EC2 capacity and a unique offering from Amazon EC2 that allows you to leverage unused computing power at significantly reduced rates with discounts often of up to 90% compared to on-demand instances.

Being that Spot Instances are interruptible, meaning they can be reclaimed by AWS at any time, they are ideal for fault-tolerant workloads, batch processing, and containerized applications that can handle interruptions gracefully.

Case Study: Schlieger Cost Optimization using Spot Instances

One of our customers, Schlieger, recently migrated from conventional servers to the AWS cloud. To manage their monthly cloud budget, they capitalized on the flexibility provided by Amazon EKS and strategically opted for Spot Instance worker nodes.

Our solution is a hybrid approach, where critical components run on On-Demand instances, while non-critical workloads utilize Spot Instances. It adheres to best practices by selecting multiple instance types for the node groups, ensuring that the chosen instances have equivalent CPU and memory resources. We deploy a cluster autoscaler that dynamically adjusts the number of nodes to ensure optimal resource utilization and application availability.

By leveraging a combination of On-Demand and Spot Instances worker nodes, we maintained a scalable and reliable workload with the core benefit of 75–80% cost savings.

Here are some additional best practices for effectively utilizing Spot Instances within your Amazon EKS environment:

spot instance infrastructure

  • Use Spot Fleet: This allows the provisioning of a heterogeneous fleet of Spot Instances across multiple instance types, sizes, and Availability Zones. Spot Fleet automatically manages instance provisioning and maintains target capacity, enhancing workload availability and reliability.

  • Leverage Spot Blocks: This offers a more predictable pricing model for Spot Instances by allowing organizations to reserve capacity for a specified duration (one to six hours). This can be beneficial for workloads with predictable runtime requirements, providing cost predictability while still benefiting from savings.

  • Graceful Termination Handling: It is essential for Kubernetes workloads running on Spot Instances to implement mechanisms for graceful termination and rescheduling to handle interruptions effectively. This ensures minimal disruption to application availability and performance.

Conclusion

Optimizing Kubernetes workloads on AWS EKS using Spot Instances is a smart strategy for cost-conscious businesses. By following best practices and leveraging Spot capacity, you can strike the right balance between cost efficiency and performance. At StormIT, we understand the importance of cost optimization in the AWS Cloud. That's why we offer our expertise in the Well-Architected Review framework with the option to focus specifically on the cost optimization pillar.

Similar blog posts

See all posts
CategoryArticles

A Renewable Industry Customer's Journey with Amazon DynamoDB

Learn how a renewable energy company optimized latency, costs, and scalability with Amazon DynamoDB.

Find out more
CategoryCase Studies

Srovnejto.cz - Breaking the Legacy Monolith into Serverless Microservices in AWS Cloud

The StormIT team helps Srovnejto.cz with the creation of the AWS Cloud infrastructure with serverless services.

Find out more
CategoryNews

Introducing FlashEdge: CDN from StormIT

Let’s look into some features of this new CDN created and recently launched by the StormIT team.

Find out more
CategoryCase Studies

AWS Well-Architected Review Series: Renewable Energy Industry Client

See how StormIT optimized a renewable energy client's AWS infrastructure through the Well-Architected Framework. Explore now...

Find out more
CategoryCase Studies

Microsoft Windows in AWS - Enhancing Kemper Technology Client Solutions with StormIT

StormIT helped Kemper Technology Consulting enhance its technical capabilities in AWS.

Find out more
CategoryCase Studies

Enhancing Betegy's AWS Infrastructure: Performance Boost and Cost Optimization

Discover how Betegy optimized its AWS infrastructure with StormIT to achieve significant cost savings and enhanced performance. Learn about the challenges faced, solutions implemented, and the resulting business outcomes.

Find out more