It is critical for organizations wanting to be “true cloud natives” to eliminate the concept of server-based infrastructure by switching to containerization and serverless cloud app deployments. AWS Fargate can help you in this endeavor.

Check out this post to learn what AWS Fargate is, how it can be used with ECS and EKS, its top features, pricing, and more.

Fargate Overview

AWS Fargate is an Amazon-managed service that functions as a serverless compute engine for the containers. It can be used with Amazon ECS (Elastic Container Service) and Amazon EKS (Elastic Kubernetes Service). According to AWS, Fargate eliminates the need for you to manage the infrastructure requirements so that you can entirely focus on building applications.

In other words, AWS Fargate is a managed container on-demand service that doesn’t require you to create or manage the infrastructure. It enables faster application launches and seamless scaling while also providing you with complete control right from the container level.

How Does AWS Fargate Work?

Fargate efficiently combines the valuable advantages of serverless infrastructure (zero maintenance, enhanced security, and no upfront costs) and containers (resiliency and scalability).

So, how does AWS Fargate work? In order to understand the working of Fargate, it is critical to learn about its workload scheduling and infrastructure scaling capabilities. Take a look-

AWS Fargate Scheduling and Scaling

Fargate non-users are required to launch EC2 instances for hosting their containers. After those instances have been provisioned, ECS and EKS are tasked with scheduling the defined applications. To maximize the resources of your instances, the scheduler will try to place as many applications as possible within the same instance, if possible.

When an instance fills up or doesn’t have any more resources as you continue to deploy more containers to the cluster, AWS automatically adds more instances if you’ve enabled cluster autoscaling (on ECS) or cluster autoscaler (on EKS).

Using Fargate with Amazon ECS

ECS is a leading managed container orchestration service offered by AWS. The cloud-based service is compatible with several AWS services. Linux container users can launch their ECS workloads, own EC2 instances, or both on Fargate. However, you can only run EC2 instances with Windows containers.

Tasks are logical units in which your containers are grouped in ECS. Users are allowed to launch copies of their tasks in the form of services. The task definition will specify all the task details, including task size. The values (CPU and memory) you specify should align with any of the combinations available in the official Fargate Support Configurations, or else, it will result in an error.

When the ECS cluster is created, you can specify a capacity provider for designating the infrastructure type for running the task. For instance, you can choose from Fargate Spot, Fargate, or your own EC2 instances. This is critical to ensure that the Fargate resources are made available to you at a variable but reduced price, depending on the market demand.

You can also choose more than one capacity provider from the capacity provider strategy section and even assign weightage to each provider for the right blend of infrastructure you need for your cluster.

Using Fargate with Amazon EKS

EKS is an AWS-managed Kubernetes service. Like ECS, EKS is integrated with various AWS services. It can be used for hosting your EC2, Fargate, or both EC2 and Fargate containers.

In EKS, an instance group that communicates with the same API server of Kubernetes is known as a cluster. Every resource of Fargate compute runs one pod, which can include one or multiple containers. With EKS, users are allowed to create single or multiple Fargate profiles, each with their specific selectors, which determine the cluster pods that will be deployed on Fargate.

After associating a profile with the cluster, AWS will automatically detect the pods specified in the Fargate profile and lead them to the launch stage. After launching the pod, it will choose the computer resource that aligns with its resource requirements. The larger of the largest init container of the pod and the sum of all the application container requests are chosen for calculating the required memory.

Once the calculation is complete, Fargate also adds an extra 256MB for running the Kubernetes component before rounding it up to the closest memory value as per the official Fargate Configuration.

Top Features of AWS Fargate

Here are some of the top features of AWS Fargate-

  • Server Clusters Managed by Fargate

As a Fargate user, you only have to deal with the containers and designing and developing applications. You won’t be required to manage your EC2 instances, choose instance type, manage cluster scheduling, or optimize cluster utilization. Fargate will take care of all of these activities for you.

  • Seamless Scaling

With AWS Fargate, application scaling on the cloud has never been easier. You’re not required to provide adequate resources to the applications. Once the requirements are defined, Fargate will ensure that the required resources and even the scaling requirements are always available. With Fargate, hundreds and thousands of container applications can be scaled within seconds.

  • Integration with AWS ECS

You can also integrate Fargate with ECS. Like ECS, Fargate only requires users to define their application into tasks, memory, and CPU specifications. IAM policies and networking requirements of the containers should also be specified and uploaded to ECS. After completing the setup, Fargate will launch the application and also assist with container management.

When to Use AWS Fargate?

Here are a few scenarios where Fargate can help-

  • Eliminating cluster/container management of EC2 instances
  • Lacking clarity on compute/workload resource requirements in the longer run, making it difficult to choose the right type of EC2 instance
  • Cost-optimized and scalable deployments with pay-as-you-go pricing
  • Getting rid of the challenges of dealing with cloud infrastructure, maintenance, OS patching, etc.
  • Infrequent or scheduled activities such as database archiving/backups where EC2 is required for running activities that stop when completed

AWS Fargate Pricing

Like Amazon ECS, you get the serverless architecture advantage with AWS Fargate. It means that you’re only required to pay for the resources you use. Technically, you’ll pay for the amount of memory and vCPU resources that your containerized application uses.

Conclusion

In this blog, we offered a brief overview of AWS Fargate, how it works, and some of its top features. The scalability, ECS compatibility, and pay-as-you-go pricing model of Fargate are ideal for scenarios with less and unpredictable workloads. It eliminates the need to reserve infrastructure and pay unnecessary expenses of underutilized resources.

While you can always upgrade to reserved EC2 instances when the workload becomes predictable, high, and consistent, AWS Fargate will offer significant savings until you reach that stage. 

Leave a Reply