An Overview of AWS Elastic Container Service (ECS)

Containerization is a virtual method used to deploy and run distributed applications without launching an entire virtual machine for each application individually. This approach is changing the way businesses develop and deploy applications in cloud environments. Many businesses are turning their heads towards it, and as a result, the demand and the need for Container orchestration surged drastically over the years. AWS Elastic container Service (ECS) is a cloud service that makes it easier to deploy and manager your container applications.

The biggest reason behind the buzz of container orchestration services such as ECS is that it allows developers to focus only on applications and not be concerned with deployment and infrastructure management.

In this article, I will talk in-depth about the Amazon Elastic container service or ECS in short, where I stress much on explaining what Amazon ECS is and followed by how Amazon ECS works from a user perspective. So, without any further delay, let’s jump right into the topic.

Prefer to watch a video instead? Check out my YouTube video on this topic.

What is Amazon Elastic Container Service (ECS)

Amazon Elastic Container Service (ECS) is a scalable container management service offered by Amazon Web Services (AWS) with a high-performance container orchestration service that supports Docker containers. It bypasses the need for you to install and operate your own container orchestration software, manage and scale a cluster of virtual machines, or schedule containers on virtual machines.

It helps developers with AWS accounts deploy and manage scalable applications that run on groups of servers called clusters through an application program interface (API) calls and task definitions to be deeply integrated into the AWS ecosystem.

Significant Benefits of AWS ECS

  1. Supports autoscaling to handle variable Volume
  2. Cost-effective
  3. Various management methods, including the AWS console, the AWS API, or CloudFormation templates.
  4. Highly scalable without need to manage the cluster masters.

Infrastructure Option Overview for AWS ECS

In order to run docker containers, you need some kind of infrastructure to run them, and for that, there are two options available.

  1. Serverless option, which is sometimes called Fargate
  2. Managed Instance that comes with EC2 Instance

1. AWS ECS using Fargate

Fargate is a technology of Amazon ECS that allows you to run containers without need of managing servers or clusters. AWS Fargate eliminates the need to create, configure, and scale clusters of virtual machines to run containers. It also eliminates the need to select server types, decide when to expand the cluster, or optimize cluster packaging.

AWS Fargate is completely serverless and removes the need for you to interact with or even think about servers or clusters. This helps developers to focus only on designing, programming, and building their applications instead of managing the infrastructure that runs them.

2. AWS ECS using EC2

EC2 stands for Elastic Compute Cloud, is a service offered by AWS that allows users to rent virtual computers on which to run their own computer applications. Unlike Fargate, this is a managed container orchestration service where Users can manage their container orchestration with ECS using EC2. Here users need to take care of software upgrades, patches, identifying security vulnerabilities, and so forth.

There is a little bit of extra work for you to do if you decide to go with the EC2 option when you’re running an ECS task or cluster.

How to Choose EC2 or Fargate For Your ECS Cluster

Many of you might have understood the different options available to run AWS ECS i.e is by using Fargate or EC2 but are not sure when to pick the right one. So, Let me clear this for you.

If you’re just getting started or looking for a serverless way of managing ECS, then Fargate is a lot more hands-off for you to relinquish a lot of the control that comes with setting up your infrastructure.

But if you have some kind of use case that requires specific EC2 configurations, then you may want to go with EC2, or if you even have just some EC2 instances lying around, you can always just use those for your cluster. Now, to be scalable, ECS supports auto-scaling, which allows you to handle variable volume so as your traffic rises and falls, you can set up auto-scaling such that on a certain metric. This is very useful from an availability perspective and ensures that your service always has enough infrastructure to keep it healthy and serve all the traffic coming.

Check out this video on the comparison of EC2 vs ECS vs Lambda.

Hopefully, by now, I anticipate that you got an overview of the Amazon Elastic Container (ECS), and all the above-given information made sense to you, so now let’s move on to know how ECS works from a user perspective.

How Amazon ECS works

A complete overview of how ECS works. We’ll walk through each step in this article

If you’re right in the console and you’re trying to set up an ECS, then it all starts with you, “the user.”

Step 1 – Define Your Docker File

The first and the foremost thing you come up with is you define a docker file to run your tasks and if you are unsure of what exactly I mean by a docker file, then first let me brief you about what is docker and then Docker file before I move ahead in this setup.

What is a Docker file?

Docker is a software product that serves as a platform as a service that is majorly used to configure OS-level virtualization to deliver software in packages called containers. A container is a standard unit of software that packages up code and all its dependencies, so the application runs quickly and reliably from one computing environment to another.

It is an open platform for developing, shipping, deploying code, and running applications that reduces the delay between writing code and running it in production. Usually, a docker file contains references to the source code, dependencies, port mapping configurations, and other things like startup scripts. Here’s a great getting started tutorial to build a Docker file.

Step 2 – Upload Docker File to ECR

Once you are ready with your docker file now, you build that into an image ( image is a lightweight, standalone, executable package of software that includes everything you need to run an application i.e., code, runtime, system tools, system libraries, and settings)  and upload that to Amazon ECR.

Amazon ECR stands for elastic container registry, and it is a place where your images are hosted that will be launched onto your ECS containers.

Step 3 – Define your ECS Task

After you’ve uploaded your docker image to ECR and associated it with a name, the next comes ECS and on ECS; the first thing you need to do is define a task. You can think of a task as kind of it’s an abstraction on top of a container, and it’s essentially a construct of guidelines in ECS that tells ECS how you want to spin up or down your docker containers. Usually, a task can contain more than one container with the same or different configurations to support various operations in an application.

Step 4 – Set Up Your Cluster

Now, after you’ve set up your tasks, the fun bit comes in terms of setting up the cluster, and with a cluster, you can essentially think of it as an abstract resource form. So if you’re using EC2 instances, then you would set up your instances within this cluster, and they’re going to be targets for whatever you define in tasks.

Check out this blog to know how to Install AWS CLI on windows 10

What happens in this relationship is when you specify this task and map it to this cluster, then you use a user to take the task to run it on this cluster.

In the case of using EC2 and not Fargate, you specify EC2s with a cluster results in an ECS agent getting installed on your EC2 instances. That ECS agent communicates with your ECS cluster and receives requests to launch any new software or do anything relevant for that cluster. The agent is responsible for seamless internal communication between your cluster and your EC2 instances.

Real-time use case scenario

Imagine a scenario where you have an application that runs many tasks and many instances all at once; then you can simply say them to run these tasks, and that will automatically be deployed to the available resources. That is one option, and that’s great for kind of short-lived jobs, maybe like batch data processing where you just spin up and down clusters.

Suppose you have a long-running application where you know you want to spin up a container that’s hosting an application and a database to keep it running all the time to meet traffic demands. In that case, we have a slightly different approach that is setting up a service on top cluster. In this configuration, you’ll want to set up an ECS Service to maintain your infrastructure at all times.

Conclusion

If you’re looking to manage your cluster configurations on ECS, then EC2 is the right choice for you, and if you are just getting started or want to keep yourself not to worry about infrastructure management, then Fargate is the right choice.

If you are looking for guidance on “How to Deploy a Dockerfile to ECS in real-time,” then I have another great video explaining everything in detail right in the console. Please feel free to have a look.

I hope this blog helps you get an overview of AWS ECS, and on this note, I also encourage you to feel free to subscribe to my newsletter and see you soon with another exciting blog post. Until then, keep learning more about AWS.

Exit mobile version