Deep dive into AWS Fargate

Viyaan Jhiingade
4 min readAug 7, 2020

Hi, in this article we will discuss what is fargate, what is the need of fargate, We will also discuss a few key concepts required to know before you jump into fargate.

But first, why AWS launched Fargate when amazon had many popular options like EC2 and Elastic Beanstalk.

Life before Fargate

Initially, developers use to deploy and run their applications in Amazon EC2 instance. Developers could copy their jar or war file directly into the machine and deploy them. Now here the problem is EC2 instance should have all the necessary libraries installed before deploying your application. Suppose, you to have deployed your spring boot app. you need to have JRE installed, open required ports. manage logs manually. install cloudwatch agent to stream logs into AWS Cloudwatch. And to maintain uptime and to scale the application is a tedious task. And not to forget to assign proper roles for the ec2 instance.

Then came docker where developers started to package their application into a container and launch them in an EC2 instance these containers are OS agnostic. So multiple containers could run in a single machine.

The container is an atomic package, that contains everything you need to run your code. And docker is one of the widely used container platforms.

Docker becomes more and more popular and since multiple containers were launched in multiple instances and it was getting more and more difficult to manage them all.

That’s when amazon came up with a new offering known as ECS (Elastic container service). Which made the life of developers easier as they don’t have to manage and maintain all these servers and containers.

ECS kept track of all instances and applications running on all these instances and also kept track of no of resources used by these containers and resources that are still available.

Now user’s life was made easier as they no longer even have to manage the configuration of these instances which form the cluster. An instance, in general, has a docker daemon installed, no of containers, OS, cloud-specific agents like cloud watch and many more. Managing these for a single instance sounds easy rite. But think of a fleet of instance that sounds too cumbersome to maintain.

But no longer, aws fargate was introduced which manages all these for you.

Here fargate acts as a compute engine and user no longer have to deal with EC2 instance. Fargate will host your application and scale them for you.

“AWS Fargate removes the need for you to interact with or think about servers or clusters”

So how do fargate works?

First, we create a container image. This container image is stored in a docker repository, there are multiple repositories available in the market like Docker hub, AWS launches its own repository as ECR know as elastic container registry. From these registries, you can download your image whenever you want and run on your cluster.

Now next step is you need a container manager or an orchestrator. Kubernetes is the most popular tool used in the market, we also have docker swarm. Amazon comes with its own service ECS.

Next, we will create a cluster to store all the containers and the resources you have assigned to your application. Now amazon gives you two choices EC2 or Fargate.

While configuring your fargate, you will be asked to configure your cluster which will enable fargate to manage all your underlying infrastructure and the cluster for you. Once all the configuration is done, your application will be deployed and you should be good to access your application.

Benefits

  • Developer need not worry about operational overhead of scaling, patching, securing and managing your servers.
  • Rite size for all, Fargate launches and scales the compute based on what we specified while configuring the container in the task definition.
  • With fargate, there is no possibility of over-provisioning and you pay only for what you use.
  • Inbuilt provisioning, fargate offers inbuilt out-of-box built-in integrations with other AWS services including Amazon CloudWatch Container Insights. Fargate also allows you to gather metrics and logs for monitoring your applications.

So how do I choose

Depends on how much control you need to have.

Fargate: If you can configure with just a Task Definition, and you are ok with awsvpc networking mode,

EC2: if you need more customization.

The below image is taken from the AWS official website. It explains how the application was deployed with and without fargate.

Drawbacks

No support for ELB Classic, only ALB and NLB.

Windows container only for Ec2 not available for fargate.

Youtube

To know more about AWS Fargate, please go through my video.

--

--