Amazon EKS vs. Amazon ECS vs AWS Fargate

The Amazon Elastic Compute Cloud (EC2) may just be the most fundamental and important service in AWS. Many other services in the AWS ecosphere are built on top of EC2. You can think of an EC2 as an individual server. However, if you look underneath the hood, an EC2 is not implemented as a physical server, but rather as a virtual server. A virtual server is a “slice” of a physical server. A physical server can support multiple virtual servers and make it appear like it is multiple instances. On the other hand, a container is also an artifact that “slices” up a physical server and makes it appear like it is also multiple servers.

So, if an EC2 is a virtual server and virtual servers “slice” physical servers, why do we need containers? The one-word answer is elasticity. What do we mean by that? Even though the E in EC2 stands for “Elastic”, EC2s are not that elastic. Anytime you provision an EC2 and don’t give it a workload right away or you assign it a small workload that doesn’t use much of the memory, this will cause the CPU idle time to be relatively low and the server will be wasted doing nothing.

If you have variable workloads that require a lot of capacity one moment and not much capacity the next, if you are only using EC2s and not containers, you will be forced to provision an expensive instance type that will remain idle when there isn’t much demand.

On the other hand, if you are able to use containers for this use case, the underlying architecture will provision and shut down instances as needed without any manual intervention. In this case, you will be able to use a set of less expensive instance types. The system will automatically provision more servers when demand is high and shut down any unneeded servers when demand is low.

One of the first entries in the container field is Docker. Many of the AWS services that offer containerization use Docker as a core technology. Some of the container services offered by AWS are:

  • AWS Fargate
  • Amazon ECS (Elastic Container Service)
  • Amazon EKS (Elastic Kubernetes Service)

Docker was initially released in 2013 at the PyCon conference. From the beginning, it caught fire. And a year later, Amazon released the Amazon Elastic Container Service (ECS).

Amazon Elastic Kubernetes Service (EKS) was released much later in 2018. And it wasn’t until April 2019 that AWS Fargate was launched.

So how do these services stack against each other? When should I use which? Let explore that.

Amazon ECS

Amazon ECS can be described as Amazon’s “Docker” as a service. It provides the management of the underlying infrastructure and enables us to focus on building applications and services on top of this infrastructure. Could we install Docker ourselves on a fleet of EC2s? Yes, you can but that would mean that we would have to manage the management, patching, workload distribution, scheduling, and recovery ourselves. That is not a trivial task. In rare cases, it may make sense to keep complete control and deploy Docker directly but make sure that you are able to justify to your boss why you decided to go with this option.

Amazon ECS takes care of all this infrastructure management. Amazon ECS also provides support via the CLI for Docker Compose which provides the ability to launch multiple containers in batch. Amazon ECS also can integrate seamlessly with the Amazon Elastic Container Registry (ECR). Amazon ECR provides the ability to manage Docker Images.

Another feature of Amazon ECS is the ability to self-heal. If for some reason, one of the Docker containers goes down or fails, Amazon ECS will automatically take that container out of the cluster and replace it with a healthy one.

Like many other AWS services, Amazon ECS can seamlessly with:

  • Amazon Elastic Load Balancers (ELBs)
  • AWS Identity and Access Management (IAM)
  • Amazon CloudWatch
  • Amazon CloudTrail

Amazon ECS can easily scale to hundreds of containers and it’s a great option when building a development environment that can be easily stood up and broken down.

Amazon EKS

Like Amazon ECS, Amazon Kubernetes also integrates with:

  • Amazon Elastic Load Balancers (ELBs)
  • AWS Identity and Access Management (IAM)
  • Amazon CloudWatch
  • Amazon CloudTrail

While Amazon ECS simplifies the process of managing Docker containers, Amazon EKS provides an additional layer of functionality to enable scheduling and clustering. This functionality is possible thanks to Kubernetes. And Amazon EKS simplifies the management of Kubernetes. By doing so, it again allows us to focus on building applications and services and not have to worry about the management of the underlying infrastructure.

But wait… There’s more. Amazon has come out with a third container service — AWS Fargate. We will delve into it in the next section.

AWS Fargate

AWS Fargate does not host additional types of containers. Rather it is a launch type. Why is it important? This may not seem important but AWS Fargate is a game-changer.

Managing Kubernetes is complicated. It requires knowledge on how to:

  • Provision servers
  • Scheduling
  • Management of master nodes, minions, pods, services, and containers
  • Orchestration

In short, it requires DevOps engineers that know how to manage it. Amazon Fargate takes care of all of this. It streamlines and simplifies deployments enabling faster delivery. Another advantage of AWS Fargate is that you don’t have to commit to using it. You can begin your development using Amazon ECS or Amazon EKS, perform your testing and then you can migrate to AWS Fargate.

AWS Fargate takes care of the placement of resources, scheduling, scaling, and patching; it eliminates most of the work required to manage containers.

So in general, if you don’t need complete control over containers, AWS Fargate is a great option to deploy containerized applications.

Conclusion

Containers are here to stay. At this point, it’s not a matter of will we containerize our applications but rather when. Managing Docker without an underlying service like the ones we reviewed in this article is less and less common. Kubernetes is growing in popularity by the day. All three major cloud providers are racing to provide a variety of services that can support containers and facilitate application development on top of them. And at this point, Amazon ECS, Amazon EKS, and AWS Fargate are quite mature and only keep getting better.

Originally published at http://thedatascience.ninja.

Data Scientist, Artificial Intelligence, Machine Learning, Author of “Artificial Intelligence with Python”