In this lesson you will learn how to choose between Amazon EC2, containers and serverless based on how much control the workload needs and how much operational work the team accepts, how long a Lambda function can run and how much memory it has, and how to read the name of an instance type to pick its family.
Compute is the capacity to process: what runs an application's code when someone uses it. On AWS that compute is rented in several forms, from a whole server to a piece of code that runs for only a few seconds. On the SAA-C03 exam, a compute question describes a workload and asks you for the service that runs it. The AWS decision guide for compute compares the services on several criteria, such as the type of workload, performance, scalability, cost and latency. Of those criteria, the two that set the services apart the most are how much control over the server the scenario needs and how much operational effort, that is, maintenance work, the team accepts. For example, an online store with a small team prefers a service where AWS looks after the servers, even if it has less control over them.
AWS compute services
The guide groups the compute services by what they solve, and these are the four groups you need to tell apart:
Amazon EC2, which gives you virtual computers, called instances, that you choose and manage.
Containers, which are packages with an application and everything it needs to run, so it works the same on any machine. Amazon ECS and Amazon EKS run the containers, spread them across machines and keep them running.
Serverless, where AWS Lambda and AWS Fargate run your code or your containers without you managing servers.
Services on premises and at the edge, which are AWS Local Zones, AWS Outposts and AWS Wavelength, for when you need very low latency or the data has to stay in one place.
With Amazon EC2, installing, scaling, patching and securing the servers is your job, including their operating system. Amazon EC2 Auto Scaling, EC2 Image Builder, AWS Elastic Beanstalk and Amazon Lightsail are in that same group. For example, if the store runs its website on EC2 instances, its team has to install the security updates on each instance.
In the containers group, Amazon ECR stores the container images, which are the templates each container is created from. There is also AWS Batch, which runs batch jobs, that is, many long tasks that line up in a queue and don't need an immediate answer, on ECS, EKS, Fargate and Spot or On-Demand Instances. For example, a bank that calculates the interest on all its accounts every night has a batch job.
In the serverless group, AWS Lambda runs your code when an event arrives, such as a new file or a click, and AWS manages the servers, the operating system, capacity, scaling and logs. AWS Fargate, for its part, runs containers without you managing servers or groups of EC2 instances, which are called clusters. For example, the store can use Lambda so that every time someone uploads a product photo, a small version of that photo is created.
How much of the server is yours?
Each band is a security layer, from the hardware at the bottom to your data at the top. Choose a service and see where the line falls between what AWS does and what you do.
You
AWS
The line between the two
Amazon EC2: 5 of 6 layers are yours.
In Amazon EC2 you rent a virtual machine and almost everything that runs inside it is yours: the guest operating system with its patches, the security groups, the credentials to log in to the instance and the IAM roles you assign to it. AWS keeps the hardware and the facilities.
The closer you get to serverless, the less you manage and the less control you have over the server. Elastic Beanstalk sits in the middle, because you upload the code of a web application and the service creates the EC2 instances and applies the operating system and runtime updates to them. For example, with Beanstalk the store uploads its application and doesn't prepare the instances by hand, but it can still log in to them if it needs to.
Memory and duration of a Lambda function
In a Lambda function you only choose the memory, from 128 MB to 10,240 MB, and the CPU increases in proportion, so at 1,769 MB the function has the equivalent of one vCPU. That is why AWS says memory is the main lever for a function's performance, and a function that is slow for lack of CPU is also fixed by increasing the memory. For example, if the function that shrinks the store's photos takes too long, you increase its memory and with that it gets more CPU.
A Lambda invocation, which is each time the function runs, lasts up to 15 minutes (900 seconds). The exception is functions on Lambda Managed Instances, which reach 90 minutes in two cases: in asynchronous invocations, where whoever calls the function doesn't wait for the answer, or when the function reads messages from another service with an event source mapping. Outside that exception, a job longer than 15 minutes doesn't fit in a Lambda invocation. For example, converting a photo fits easily, but a process that takes an hour has to go in another service.
Containers without servers with AWS Fargate
With Fargate, containers run without EC2 instances to manage. An ECS service set up this way spreads its tasks across private subnets in several zones, behind a load balancer.
In that service there is no EC2 instance. Each task, which is a container or a group of containers that run together, has its own network interface and its private IP address in its zone, and the Application Load Balancer treats them as targets it sends visits to. For example, if the store has two tasks for its website in two zones and one zone fails, the load balancer sends all the visits to the task that is still running.
With Fargate you only declare the CPU and memory of each task, so you don't choose a server type or decide when the cluster grows. The orchestrator, which is the service that decides where each container runs, can be ECS, which is AWS's own, or EKS, which is managed Kubernetes. Kubernetes is a widely used open source orchestrator, so if the scenario says "Kubernetes", the answer is EKS. For example, a company that already runs its containers with Kubernetes in its data center can bring them to EKS without changing how it works.
Which compute service?
0 of 5
Tap the service that does it with the least operational overhead.
Resize each image uploaded to an S3 bucket; each one takes two seconds
An API already packaged in Docker containers that runs all day
An application with a license tied to the operating system that needs an agent installed on the server
Thousands of nightly simulations that are queued and run in parallel for hours
A containerized process that takes three hours per run
EC2 instance families
When the answer is EC2, you still have to choose the instance type, which defines how much CPU, memory, disk and network the virtual computer has. AWS has more than 750 instance types, and the name of each one tells you what it is for.
The name of an instance type has four parts, in this order: series, generation, options and size. The series is the letter the exam uses, and these are the series you need to recognize:
M, which is general purpose and is used when the workload doesn't need more CPU, memory or disk than usual.
C, which is compute optimized and is used for intensive processing and complex calculations.
R and X, which are memory optimized and are used for large databases and in-memory caches.
I and D, which are storage optimized and are used for workloads with many disk operations.
T, which has burstable performance: it works with little CPU most of the time and can use more for short stretches.
P, which has GPUs, and G, which is for graphics.
Inf and Trn, which use AWS chips for machine learning: Inferentia to use a model that is already trained (inference) and Trainium to train it.
For example, the store's website, with normal traffic, runs well on an M instance, while its large in-memory product cache goes on an R instance.
The letter "g" after the generation indicates an AWS Graviton processor, which is a processor designed by AWS. According to the guide, Graviton instances give up to 40% better price performance than comparable non-Graviton instances, so it is worth keeping them in mind in cost questions. For example, m7g.xlarge is general purpose, seventh generation and with Graviton.
Match each workload with its instance family
0 of 5 pairs
Tap a workload and then the family.
0 of 5 pairs.
If your account uses the new experience
In a new experience account, EC2, EC2 Auto Scaling, Lambda, ECS, EKS, AWS Batch and Elastic Beanstalk are in the free plan. AWS Outposts isn't available and Lambda@Edge doesn't work.
In the paid plan you can set a spending limit on your project, and when the project reaches the cap, AWS pauses it and stops its resources. The free plan doesn't have spending limits. For example, if you set a limit on your practice project and reach it, your instances stop instead of continuing to charge.
On the exam
The questions on this topic describe the workload and what the team doesn't want to do. These words in the question point to the service:
"Least operational overhead" with short events, which points to Lambda, and with containers, which points to Fargate.
"Kubernetes", which points to EKS, and "batch jobs", which points to Batch.
"Just upload the web application's code", which points to Elastic Beanstalk.
"Control of the operating system" or "software installed on the server", which point to EC2.
"More than 15 minutes", which rules out Lambda except for the Lambda Managed Instances exception.
"Best price performance", which points to Graviton instances.
"Low latency for users in a large city", which points to Local Zones, and "in our data center", which points to Outposts.
For example, if the question says "the team doesn't want to manage servers and the application is already in containers", the answer is Fargate.
Review question
A company runs an order processing service in containers on EC2 instances, and its team patches and scales those instances by hand. They want to stop managing servers without rewriting the application. What do they do?
Next
Choosing an AWS compute service, the AWS decision guide. The "Consider" section has the criteria and the "Choose" section has the table by category.
Take a Solutions Architect practice exam at /examenes.