AWS Architect Certification Training
- 57k Enrolled Learners
- Live Class
Containerization has transformed cloud architecture over the past few years, allowing businesses to build, deploy & manage applications at a faster rate. And the momentum behind containers certainly is not showing any sign’s of slowing down. There are a plethora of container & container orchestration services that are available today. Most of them, however, still require you to configure and manage clusters of virtual machines for the containers to run. This is where AWS Fargate comes into the picture.
In this article, we will be learning about AWS Fargate, a serverless computing platform for containers. The topics which we will be covering in this article are as follows:
Let’s get started!
When container services still didn’t exist, users used to launch their applications on virtual machines. In AWS cloud they deployed applications on EC2 instances. They packaged their application with OS into what we call an Amazon Machine Image(AMI) and then run it on AWS EC2 instance.
Then docker introduced containers, and people started deploying their applications on these containers. Containers resemble VM. One major difference is that unlike VM’s, containers share the host system’s kernel with other containers. The diagram below will make it more clear.
So, as these containers started becoming more and more popular, people started using them at huge scale. The number of containers in an EC2 instance increased, which in turn increased the number of instances. AWS then launched Amazon Elastic Container Service(ECS).
But what is ECS service? Amazon Elastic Container Service (Amazon ECS) is a highly scalable, high-performance container orchestration service. Amazon ECS reduced some overhead which users had to manage. However, users still had to manage underlying instances that hosted container applications.
This gave AWS an idea to come up with one service that could handle the underlying virtual machines while users can focus on building their application. The said service is AWS Fargate.
AWS Fargate is a compute engine for Amazon Elastic Container Service(ECS) that allows you to run containers without having to provision, configure & scale clusters of VMs that host container applications.
AWS Fargate eliminates the need for users to manage the EC2 instances on their own. In fact, users don’t need to use EC2 instances at all. Fargate itself will act as compute engine. It lets you focus on elements like designing and constructing your application instead of managing the infrastructure that runs them. With Fargate launch type, all you need to do is package your application in containers, specify the memory and CPU requirements, define IAM policies & launch your application.
AWS Fargate also makes it easy to scale your applications. Once you define all your application requirements, AWS Fargate manages all the scaling and infrastructure needed to run your containers in a highly-available manner. It seamlessly integrates with Amazon ECS & EKS, launches and manages your containers for you.
Now how does this entire process of launching containers without having to maintain underlying servers work?
Before we see the working of AWS Fargate, let’s take a look at some general terms that you encounter frequently when you are dealing with AWS Fargate.
Container: A Docker container is a standardized unit of software development, containing everything that your software application needs to run code, runtime, system tools, system libraries, etc. These containers are created from a read-only template called a container image.
Container Image: Images are typically built from a docker-file which is a plain text file that specifies all of the components that are included in the container. These images are stored in a registry from which they can be downloaded & run in the container.
Task Definitions: The task definition is a text file, in JSON format, that describes one or more containers that form your application. You can think of it as a blueprint for your application.
Task: A task is the instantiation of a task definition within a cluster. You have the option to specify the number of tasks that will run on your cluster.
Clusters: Cluster is basically the logical grouping of resources that your application needs. If you use Fargate launch type with tasks within clusters then Amazon ECS manages your cluster resources. If you use EC2 launch type, then your clusters will be a group of Amazon EC2 container instances that you manage.
Now we are ready to venture ahead. The diagram below gives you a rough idea of how to deploy your application on ECS using AWS Fargate.
Let’s try to understand the contents of the above image. First, you need to build a container image that suits your application and then store it on a registry. Then you choose a container orchestration service, either Amazon ECS or Amazon EKS and assign resources to your application. Once you have done that you need to create a cluster to group all those assigned resources. This is when you choose AWS Fargate launch type. Now AWS Fargate will launch & run all your containers. It manages all the underlying infrastructure and clusters for you. It also seamlessly scales your application needs without you having to bother about it.
Wasn’t that very simple?
Now, let’s go ahead and deploy a simple web application on Amazon ECS using AWS Fargaet launch type.
AWS Fargate In Action
Follow below steps to deploy a simple web application on Amazon ECS using AWS Fargate launch type.
Note: Make sure you are in the AWS Region where AWS Fargate is available (You can choose N.Virginia).
Step1: On Amazon Elastic Container Service console click on ‘Get Started’ option.
You will be taken to a page where it says “Getting Started with Amazon Elastic Container Service (Amazon ECS) using Fargate”.
Step2: Create a container definition. You can always choose preloaded ones if you have just started using AWS Fargate.
Step3: Create a task definition. You can use sample task definition or optionally rename the task definition and edit the resources used by the task (such as the Task memory and Task CPU values) by choosing Edit.
Step4: Configure a service that launches and maintains a specified number of copies of the task definition in your cluster. You can use preloaded service definition or optionally rename the service or review and edit the details by choosing Edit.
Step5: As the final step you need to configure the cluster. Name your cluster, and then Amazon ECS take cares of the networking and IAM configuration for you. Then review what you have done till now and click on Create to finish.
That’s it! Your simple web application should be up and running.
Now if your service is a web-based application like the one we just launched, you can view its contents with a web browser.
Step6(Optional): Look for IPv4 Public IP address in the network section of your service & enter that in your web browser. You should see a webpage that displays the web application that you just launched.
Now you know how to use AWS Fargate launch type to launch containers on Amazon Elastic Container Service. Go ahead and explore.
So this is it! I hope this blog was informative and added value to your knowledge. If you are interested to take your knowledge on Amazon Web Services to the next level then enroll for the AWS Architect Certification Training course by Edureka
Got a question for us? Please mention it in the comments section of “AWS Fargate” and we will get back to you ASAP.