ECS vs EC2 vs Lambda

Amazon AWS ECS EC3 Lambda comparison

In this comparison article, we’ll be looking at three different computing services on AWS, namely, Amazon Elastic Container Service (ECS), the service for running Docker containers on AWS, Amazon Elastic Compute Cloud (EC2), and AWS Lambda. These services take up a huge part of the AWS exams, so make sure to learn them well because you’ll definitely need to know them in-depth to pass the test!

Let’s talk about IaaS, CaaS, and FaaS before jumping into each of the related AWS services.

Something… as a Service

Infrastructure as a Service (IaaS) is the cloud service model that says “We’ll manage the data center but you have to manage your own services.” AWS accomplishes this by providing IaaS services like Amazon EC2 so that users can provision servers without having to buy server racks themselves and then pay utilities/rent required to run a data center. This allows users to save tons of money upfront. If you’re used to working with “Virtual Machines”, think of IaaS as managed virtualization infrastructure so you only need to look after the VM.

Out of the three service models we’ll be talking about in this article, IaaS is perhaps the most intuitive, so let’s not spend too much time on IaaS and move on to containers.

Containers as a Service (CaaS) is a bit different from IaaS in that you have the option to go serverless with AWS Fargate. “Serverless” means that you don’t have to provision or manage the underlying servers in order for your application to work. AWS Fargate is Amazon’s serverless service for running Docker containers. If you’re not sure what containers are, you can just think of them as miniature instances that are very resourceful and designed to carry out specific computing tasks. AWS provides CaaS services with Elastic Container Service (Amazon ECS), Elastic Kubernetes Service (Amazon EKS), and AWS Fargate. We’ll talk more about the details of these services below. But first, let’s introduce our last main subject, functions!

Functions as a Service (FaaS) takes the concept of serverless further by saying “You just give me the code you want to run and I will take care of ALL the management and provisioning of resources.” Function computing is essentially on standby, meaning that it’s always ready to run. But FaaS services on AWS, such as AWS Lambda, only charge for the time the code is actually running, making it a cost-effective solution for most use cases. With Lambda, users provide code and then Lambda makes sure that code is run when invoked by a request. Lambda is FaaS at its finest.

So…which one should you use?

You might be wondering, “If functions are so cost-effective why wouldn’t businesses always use Lambda as opposed to containers or instances?” Similarly, you could ask, “Why should I use instances when I can always just use containers instead?” These are great questions to be asking and if you’ve had similar thoughts while reading this article that shows you’re thinking along the right lines!

One important thing to remember about AWS services is that, despite all the wonders of the cloud, each product still has its own limitations. Sure, there’s a lot of overlap between EC2, containers, and Lambda but each computing service can’t do it all. Therefore, it’s incredibly important to learn the benefits and use cases of each. So, let’s start by looking at Amazon’s original computing service, Amazon EC2.

Amazon EC2, “ya basic”

And you know what, that’s great!

With Amazon Elastic Cloud Computing (EC2), users can have a full-fledged server that runs 24/7 without having to physically manage or maintain the infrastructure needed to run it. Users simply select an Amazon Machine Image (AMI) to get started right away. An AMI is a server template that tells AWS what operating system, packages, and other settings to give the server at launch.

Shortly after choosing your AMI starting package, you’ll also get the opportunity to adjust the power of your EC2 instance. You’ll define the vCPU, memory, and other related configurations by choosing the “instance type”. If you decide you don’t want your instance anymore, that’s not a problem either. On AWS you can quickly start, stop, terminate, and launch a new one with a simple click of a button. That’s the power of the cloud.

In our courses, you’ll learn more about EC2-related services such as: Network Access Control Lists, Security Groups, Subnets, Auto-scaling Groups, and Elastic Load Balancers. All of the aforementioned services have a direct impact on how EC2 works and allow users to tailor the perfect solution for any given scenario.

Sometimes working in the cloud feels a lot like building with Legos, each piece in and of itself might not seem like much but combined together they can create something truly amazing! This is especially true when it comes to EC2 and containers.

Checkout out a couple of our exam-specific cheat sheets to learn more:

Uncontainable Containers

Containers are the “hot new thing” that’s gaining popularity throughout the IT world due to their cost-effective computations. As monolithic applications continue to be replaced by microservice applications, it’s only a matter of time before container usage becomes more prevalent than instance usage. Docker.com defines containers as “a standard unit of software that packages up code and all its dependencies so [an] application runs quickly and reliably from one computing environment to another.” Put simply, containers are standardized, lightweight, and secure pre-packaged solutions that run efficiently no matter what situation they’re thrown into.

It’s important to know that the idea of containers isn’t unique to AWS. Not only does each major cloud platform have its own container service but containers can be run without a cloud provider as well. But for the purpose of this article, we’ll be focusing on how containers are run on AWS through services like ECS, EKS, and AWS Fargate.

Amazon Elastic Container Service (ECS)

ECS “is a fully managed container orchestration service that helps you easily deploy, manage, and scale containerized applications.” (AWS) One of the great things about ECS is that, since it’s an AWS native service, it can easily integrate with the rest of your AWS environment. For example, you could run WordPress on Amazon ECS or on AWS Fargate and have Amazon EFS as your storage solution without running into any compatibility issues, just as this AWS article discusses here. Speaking of AWS Fargate…

AWS Fargate

Fargate is a serverless compute solution for containers that removes the need for users to have to provision and manage servers, thus allowing users to focus on building their application. Users give up granular configuration of the compute engine in exchange for convenience. But just because they have less control doesn’t mean they’ll overpay for anything. In fact, just the opposite is true! Fargate will ensure that a user’s application has the right compute capacity to run with no over-provisioning or wasted resources.

Amazon Elastic Kubernetes Service (EKS)

In order to understand EKS, you have to first understand what Kubernetes is. “Kubernetes is an open-source container orchestration engine for automating deployment, scaling, and management of containerized applications” (Kubernetes.io) that was originally started by Google. Kubernetes is an open-source software available for use by everybody and is well known as the tool that makes using containers at scale easier to manage. AWS makes Kubernetes available for use on their platform through Amazon EKS.

Checkout out a couple of our exam-specific cheat sheets to learn more:

It’s Lambda, not “Lame-da”

Lambda, Lambda, Lambda… If you haven’t heard about it yet, brace yourself. You’ll start seeing it pop up everywhere you look in the AWS world, and for a good reason too! AWS Lambda is the king/queen of convenience. With EC2 and Fargate you still have some type of control over the compute engine but with Lambda you forfeit all control for a totally hands-off experience. Submit your code, set the situations for which it’ll be invoked, and sit back, relax, and enjoy the show!

Not only do you avoid server management with Lambda but you also have continuous scaling. This means that no matter how many people are using your function (default is 1,000 concurrent uses but can be extended to tens of thousands), Lambda will grow to meet the demands. It will also remain cost-effective as it maintains constant performance for all the time it is invoked making it a perfect tool for data processing, real-time file processing, and machine learning, (to name a few).

Checkout out a couple of our exam-specific cheat sheets to learn more:

Let’s compare each of the computing services we’ve covered in the table below:

Compute Options EC2 ECS Lambda
Type of Compute Instance;
Infrastructure as a Service (IaaS)
Container;
Container as a Service (CaaS)
Function;
Function as a Service (FaaS)
Defining Features Extensive instance configuration Container orchestration Serverless function deployment
Use Cases General computing; complete control over instance Running Docker containers; running 15+ minute tasks Smaller applications that run in less than 15 minutes
Availability SLA: 99.99% SLA: 99.99% SLA: 99.95%
Scalability Combines with Auto Scaling Group to scale out/in as defined in ASG policies Automatic scaling based on desired count of tasks AWS Lambda automatically scales on your behalf
Service endpoint IPv4, IPv6 Interface VPC endpoints Interface VPC endpoints
Encryption Supports encrypted EBS volume EC2 Launch: Use encrypted EBS volumes;

Fargate Launch: Images pulled from ECR use HTTPS and are encrypted at rest w/ S3
Uses HTTPS for encryption in transit;
Uses AWS KMS for encryption at rest
Timeout N/A N/A 300 seconds (15 minutes)
Pricing Varies by instance type, time run, and launch type (spot instances, RI, scheduled, etc.) EC2 Launch: underlying resources;

Fargate Launch: vCPU & memory used

EKS: Per cluster & underlying resources
Number of requests and time it takes for code to execute

AWS Computing Summed Up

  • EC2 is for general computing. Think complete control over instance configuration.
  • ECS, EKS, AWS Fargate are for container computing. Think of Docker.
  • Lambda is for function computing. Think smaller applications and less than 15 minutes compute time.

I hope that helps you understand the differences between ECS vs EC2 vs Lambda! Of course, we can only cover so much in an article but check out our AWS courses for video lectures and hands-on labs to really learn how these services work.

Check out our AWS Training Courses!

At Digital Cloud Training we provide the highest quality AWS training courses in the market at affordable prices. Our training options include:

  • Video-based training courses that seamlessly blend theoretical education with hands-on practice so you can not only prepare to answer tricky exam questions but learn critical hands-on skills that will set you up for your next job.
  • Practice tests with large banks of questions that reflect the style and difficulty of the real AWS exam so you can be well prepared to easily pass your exam on the day. All questions come with detailed explanations and reference links and the tests are offered in multiple formats for training and exam simulation.
  • Cheat Sheets and eBooks that help you to memorize and cross-check key facts you need to know for the exam and also take your studies offline. These are great resources for final exam preparation.

Check out our catalog of courses now to get started with your AWS certification journey.

Got Questions?

Contact us here.

Related Articles