AWS Steppingstones #2- ECS Learning Series Part 02 - ECS Concepts and ECR
This short article explains the fundamentals of ECS Service and Elastic Container Registry (ECR) before we try hands-on from next time
Hello Reader,
I am sure you’re doing great today and thanks for taking time to read this post. Any kind of comments/feedback from you is always welcome. This will help me to improve myself and make the content better next time.
This is the second post in the “AWS SteppingStones” category and following it up on the previous post on Microservices, containers and Dockers as part of the ECS learning series.
Missed the previous one? Click the below link to access it.
AWS Steppingstones #1- ECS Learning Series Part 01
AWS Tip of the Week - “AWS Free Tier”
The AWS Free Tier program provides customers the ability to explore and try out AWS services “free of charge” up to specified limits for each service. This is very helpful when we want to explore AWS and its rich set of services for learning or in your certification journey to get real hands-on experience.
The Free Tier is comprised of three different types of offerings,
12-Months Free: These free tier offers are only available to new AWS customers and are available for 12 months following your AWS sign-up date. Post this period, you’ll be charged as per pay-as-you-go model based on the usage.
Always Free: These free tier offers do not automatically expire at the end of your 12 month and are available to both existing and new AWS customers indefinitely.
Trials: These free tier offers are short term trial offers that start from the time of first usage begins.
If you don’t have an AWS account yet, go ahead and create one!
AWS Free Tier Account - Click to create one
ECS Overview and Concepts
A quick review quote on the service definition from AWS.
Amazon Elastic Container Service (ECS) is a fully managed container orchestration service that helps you to more efficiently deploy, manage, and scale containerized applications. It deeply integrates with the AWS environment to provide an easy-to-use solution for running container workloads in the cloud and on premises with advanced security features using Amazon ECS Anywhere.
ECS is also deeply integrated into the rest of the AWS ecosystem and it’s a homegrown service from Amazon Web Services (AWS) and can seamlessly integrate more than 100 AWS services.
In this section, we’ll cover the fundamental concepts of ECS service and get a firm understanding on the related terminologies.
Cluster
Task Definitions
Tasks and Scheduling
Services
Fargate
Service Discovery
ECS Cluster
An Amazon ECS cluster is a logical grouping of tasks or services.
If you are running tasks or services that use the EC2 launch type, a cluster is also a grouping of container instances.
If you are using capacity providers, a cluster is also a logical grouping of capacity providers.
A cluster can be a combination of Fargate and EC2 launch types.
Task Definitions
The task definition is a text file, in JSON format, that describes one or more containers, up to a maximum of ten, that prepares your application to run in Amazon ECS.
Task definitions specify various parameters for your application such as which containers to use, which launch type to use, which ports should be opened for your application, and what data volumes should be used with the containers in the task.
A sample task definition (sample.json) would look like the one below,
{
"family": "webserver",
"containerDefinitions": [
{
"name": "web",
"image": "sample-java-web-app",
"memory": "100",
"cpu": "99"
}
],
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"memory": "512",
"cpu": "256"
}
Tasks and Scheduling
A task is the instantiation of a task definition within a cluster. After you have created a task definition for your application within Amazon ECS, you can specify the number of tasks that will run on your cluster.
The Amazon ECS task scheduler is responsible for placing tasks within your cluster. There are several different scheduling options available. For example, you can define a service that runs and maintains a specified number of tasks simultaneously.
Services
Amazon ECS allows you to run and maintain a specified number of instances of a task definition simultaneously in an Amazon ECS cluster. This is called a service. If any of your tasks should fail or stop for any reason, the Amazon ECS service scheduler launches another instance of your task definition to replace it and maintain the desired count of tasks in the service depending on the scheduling strategy used.
In addition to maintaining the desired count of tasks in your service, you can optionally run your service behind a load balancer. The load balancer distributes traffic across the tasks that are associated with the service.
Fargate
AWS Fargate is a technology for Amazon ECS that allows you to run containers without having to manage servers or clusters. With AWS Fargate, you no longer have to provision, configure, and scale clusters of virtual machines to run containers. This removes the need to choose server types, decide when to scale your clusters, or optimize cluster packing.
Service Discovery
Since containers are immutable, they can be replaced with newer versions of the service and scale faster. So, we need to register the new and deregister the old/unhealthy services and keep tracking. AWS Cloud Map is a cloud resource discovery service.
AWS Cloud Map natively integrates with ECS and increases your application availability since it maintains the updated location of these dynamically changing resources.
Elastic Container Registry
Amazon Elastic Container Registry (Amazon ECR) is a fully managed container registry offering high-performance hosting, so you can reliably deploy application images and artifacts anywhere. Amazon ECR is integrated with Amazon Elastic Container Service (Amazon ECS), Amazon Elastic Kubernetes Service (Amazon EKS), and AWS Lambda, simplifying development to production workflow.
Amazon ECR eliminates the need to operate and scale the infrastructure required to power your container registry. Amazon ECR uses Amazon Simple Storage Service (S3) for storage to make your container images highly available and accessible, allowing you to deploy new containers for your applications reliably.
What’s next?
After finishing this post, I felt the ECS concepts are covered now and adding the deployment of Java application in ECS would make it lengthier for the reader to follow it up. So, we will learn how to deploy your sample Java application in ECS and access it from the internet in the next post. We’ll also look at some of the best practices for deploying applications using the ECS service.
Happy reading and sorry if I disappointed you by missing the deployment part. I will try to have it ready and broadcast across before the next week.
Further Reading and References
Poll of the Week
Please fill this poll with your thoughts when you have time,