5 Ways to Save Costs on AWS Fargate

5 Min. Read

Image Source: Pixabay.com

AWS Fargate is an impressive innovation that lets you run containers on-demand, without managing server infrastructure, and pay only for the actual computing resources used.

Fargate has the potential to generate significant savings compared to traditional platforms like Amazon EC2 because you don’t need to pay for compute instances that “just sit there” whether you run your containers or not. However, costs can be unpredictable and quickly get out of control. In this article, I’ll provide a few tips you can use to run AWS Fargate and stay within your budget.

What is AWS Fargate?

Amazon’s Fargate is a serverless compute engine that can be used with Amazon Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). It manages container infrastructure, letting development teams focus on building applications without needing to manage servers. You specify the resources you need and pay according to actual usage, not provisioned capacity.

Fargate dynamically allocates the required amount of computing required and does not require you to select instance types and scale cluster capacity. You only pay for the resources you need to run your containers, eliminating costly over-provisioning, and the need to manage orphaned or under-utilized servers.

Fargate provides application isolation by design. It runs each pod or task in its own kernel within a fully isolated computing environment, improving security for containerized workloads.

AWS Fargate Pricing Breakdown

There are several factors that affect AWS Fargate pricing:

  • Time running—Fargate bills for the number of seconds container workloads are actually running. This is different from other compute services, such as EC2, which charge for provisioned capacity, even if workloads are not running. Costs are listed per hour but are actually billed per second with a 1-minute minimum.
  • CPU resources—Fargate has a separate charge for each virtual CPU (vCPUs) available for your workloads.
  • Memory resources – Fargate has an additional charge per GB of memory allocated to your workloads, per hour.

This pricing model makes it difficult to estimate your actual per-hour pricing. You’ll need to estimate how much CPU and memory resources your workloads will use at different times of the day and week and monitor actual usage to see your real costs.

5 Ways to Save Costs on AWS Fargate

There are 5 ways to save costs on AWS Fargate:

1. Saving Plans

Fargate Savings Plans provide discounts of up to 50% if you’re prepared to commit to using a certain amount of compute capacity over a term of 1 or 3 years. The amount of committed capacity is measured in terms of dollars per hour. You can choose to pay part or all of the amount upfront to get an additional discount.

Keep in mind that Savings Plans on Amazon may include other services such as EC2 or Lambda. Amazon applies the Savings Plan discount to the resource that will give the customer the highest saving, so in some cases, you may get a discount for another service, not for Fargate.

2. Spot Instances

Since 2017, AWS has provided AWS Fargate as a launch option for Amazon ECS, meaning you can launch ECS containers using Fargate. This runs containers in a serverless model, abstracting the underlying servers, and making them easier to manage.

Fargate Spot is a new purchasing option that provides significant discounts by leveraging Amazon’s spare capacity. You can create two types of ECS tasks—On Demand tasks that use regular compute instances and Fargate Spot Tasks that use spot instances.

Fargate Spot works in the same way as Amazon EC2 Spot Instances. If you request a Fargate Spot Task, it will run when the Fargate Spot instance capacity is available.

Spot Task prices may change from time to time, and provide a discount of between 50-70% of an On-Demand Task. However, note that Fargate Tasks may be suspended if required by AWS, with two minutes’ notice. Plan your workloads accordingly.

3. Resource Tagging

Tagging resources gives you more control and greater visibility. It is especially useful for managing multiple environments such as test, staging, and production environments. By tagging your resources on Fargate, you can quickly identify which pods are in use so they don’t become unused, or consume more resources than expected.

AWS has its own built-in tagging, or you can use Kubernetes native tagging. If you use the AWS mechanism, you can also monitor your tagged resources in the AWS Billing and Cost Management console. This allows you to better manage costs and evaluate resource classification.

4. Right-Sizing Tasks

Reasonably sizing your Fargate tasks is an important step to optimizing costs. If you build an application on Fargate and do not go back to review your configuration, it is likely you will over-provision resources for some Fargate tasks, resulting in waste.

When running applications on Fargate, monitor your applications to understand how certain task configurations perform under certain load conditions. Fine-tune the vCPU and memory allocated to the task, as well as the auto-scaling strategy, to get a good balance between performance and cost. Here are two ways to get the data you need for right-sizing:

After you understand application load behavior, fine-tune vCPU and memory configuration of your Fargaste tasks until you reach optimal utilization.

5. Auto Scaling

Autoscaling is another excellent way to save on Fargate. Before you start with auto-scaling, get a good understanding of application workloads and Fargate usage over time. Learn which metrics are the best predictors or application load and monitor them. You can use these same metrics to define your auto-scaling profile.

Fargate supports three scaling strategies:

  • Target tracking—adjust the number of Fargate tasks based on a target value for a metric that reflects your application load. For example, add tasks until CPU utilization is under 70%.
  • Step scaling—adjust the number of tasks based on a number of steps, triggered on the basis of CloudWatch alarms.
  • Scheduled scaling—scale the number of tasks to a known quantity on a predetermined schedule.

Efficient scaling means you never have more tasks running than you need for a certain load. Keep in mind that auto-scaling is an iterative process and it will take time to get it right. Find the right metrics and thresholds that will keep your workloads healthy while minimizing costs.

Conclusion

In this article I explained the basics of AWS Fargate pricing, and provided five ways you can save when running containers on Fargate:

  • Use savings plans to get discounts on Fargate, by leveraging your organization’s spend on other AWS services.
  • Use spot instances to get discounts of up to 90% on Fargate resource costs.
  • Use resource tagging to organize resources on Fargate and easily identify containers that are being invoked unnecessarily.
  • Right size tasks to avoid overpaying for vCPU and memory resources.
  • Use auto-scaling to scale down services when application loads decrease.

I hope this will help you in your journey to the effective and economical use of serverless containers.

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Related Posts

Previous

Protecting Azure Blobs using Azure Backup

Map a File Server Name to Azure File Share With DFS-N

Next

Let me know what you think, or ask a question...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Stay in Touch

Never miss out on your favorite posts and our latest announcements!

The content of this website is copyrighted from being plagiarized!

You can copy from the 'Code Blocks' in 'Black' by selecting the Code.

Please send your feedback to the author using this form for any 'Code' you like.

Thank you for visiting!