AWS Fargate is a computational engine for Amazon Elastic Container Service (ECS) that allows you to execute containers without having to provide, configure & scale clusters of VMs.
Now let’s take a little deeper and see how this AWS Fargate actually operates. From the image below, you can see as a first step you built a continuous image in this container.
You need to build it in such a way that it’s suitable for application and then you store this container image as a generous tree. Well, you have docker hub or you can use Amazon ECR and this registry, you can download the image whenever you want and run it on the cluster.
So, now you have built a container image, the next step is you choose a container management service. It should be their Amazon ECS or ECS for Kubernetes. Once you have chosen a proper container orchestration service, you need to create a cluster.
That you can store all the containers and the resources that you have assigned to your application. This is where you have to make a choice between choosing EC2 or Fargate. So, obviously, we’ll be choosing Fargate here.
Now we are launching a container and either this runs your container and manages all the handling infrastructures and cluster feed. Suppose later on if your application needs extra resources, then AWS Fargate seamlessly states your application without you having to bother about it. So well in that simple, let’s summarize what you’ve learned enough so you built a container image that is suitable for the application. Then you choose a container management service or ECS or EKS then you can launch your container using AWS Fargate launched up and this AWS Fargate will manage and configure all the underlying infrastructure instances and the clusters field.
Suppose if your application needs extra computer resources later on it will seamlessly scale all application needs without you having to bother about it.
Let’s take a look at a few key concepts that you should know when you’re dealing with an AWS Fargate.
First, we have containers, I’m sure you might have heard of docker containers and I’m sure you know what those are. A docker container is a standard unit or developer software. In simple terms, it has everything you need to kickstart your application like system libraries, code, system tools, runtime and web frameworks and many other things.
Now, these containers are created on a read-only template which we call container image. These images are built from a docker file, you can think of this docker file as a plain text file that specifies all the components that you should include in your container. So, once your docker container image is created, it is stored in the container registry like it is stored in the docker hub or you can use the Amazon ECR service. From there you can download the image whenever you want and run it on the cluster. So, it’s as simple as that you have a docker file which has all the specifications regarding your container and from this docket file you create a container image and store it in the container registry and from the container registry, you download the image whenever you want and run it on the cluster.
Then, we have a task definition. Well to prepare our application to run on the Amazon ECS service you need to create a task definition. You can think of this task definition as a blueprint for an application. So basically, it’s a text file mostly in JSON format that describes one or more containers that you’ll be using for the application. When I say it describes your containers, it includes the type of containers that you’ll be using for the application or the launch type which we’ll be using or the ports which should be open for an application to be accessed among many other things.
The following is an example of a simple task definition that defines a single container that runs on the Nginx web server and it’s using Fargate launch type. So, as you can see the simple task definition belongs to the web server family and as in the container definition, you have the name image and the memory and CPU requirements. It also sees that we are launching this container using the Fargate launch type, then you have task requirements, network mode memory and CPU requirements.
Next, we have a task well, let me give you an example. I’m sure when you write a program you might have used the class and objects like you know an object is an instance of the class. Similarly, a task is an instantiation of task definition within a cluster. So, once you’ve created a task efficient for our application you need to specify the number of tasks that will run on your cluster.
When you can always go ahead and have single tasks, but it’s always good to have a number of tasks. Suppose one of your tasks fails, then your other tasks will be in the picture. Then, you have the Amazon ECS task scheduler it’s responsible for placing your tasks within your cluster. That has several different kinds of scheduling options available, but mostly you can go ahead and define a service that runs and maintains a user-specified number of tasks simultaneously.
The task scheduler is responsible for placing these tasks within your cluster, but what is cluster well, it’s logically a group of resources that you’re assigned to your application. Suppose, if you are using the Fargate launch type within your cluster then Amazon ECS will manage all your cluster resources. But if you’re using easy-to-launch, then all your clusters will be considered as a group of container instances which you will have to manage.
So, guys now you know what containers are and how containers are actually created, then you know what task definition is.
If you require help, contact SupportPRO Server Admin