Skip to Content

Compute

Where code runs on AWS, from customer-managed virtual servers to functions AWS runs on demand, and how to pick between them.

What it is

Compute is the processing power that runs code: CPU, memory and the network around them. AWS offers it at several levels. At one end the customer rents a whole virtual server and manages everything on it. At the other end the customer hands AWS a function and AWS runs it only when needed.

This group covers Amazon EC2 in depth, because almost every other service builds on it, plus the compute services that sit around it: Elastic Beanstalk, AWS Batch, the hybrid and edge options, and Compute Optimizer. Containers (ECS, EKS, Fargate) and Lambda have their own groups later.

How the options compare

Compute options from more control to less to manage: EC2, Elastic Beanstalk, containers, Lambda Compute options from more control to less to manage: EC2, Elastic Beanstalk, containers, Lambda

From more control to less to manage.
  • Amazon EC2 provides virtual servers. The customer chooses the operating system, install the software, patch it and decide how many servers run. Most control, most work.
  • AWS Elastic Beanstalk runs EC2 as a managed layer. The developer uploads the code; Beanstalk creates the servers, load balancer and scaling, which remain visible and changeable.
  • Containers (Amazon ECS, Amazon EKS, AWS Fargate) run an app packaged as a container image. With Fargate there are no servers to manage at all.
  • AWS Lambda runs a function when an event happens and bills by the millisecond. Nothing runs, and nothing is billed, when there's no work.

AWS Batch doesn't fit on that line: it's a job scheduler that runs batch jobs on EC2, Spot or Fargate capacity as a managed service.

Example

An online shop might use all of them. The legacy order system runs on EC2 because it needs a specific Windows version. The new storefront runs as containers on Fargate. Lambda resizes product photos when they're uploaded. Every night, AWS Batch rebuilds the product recommendations.

In this group

EC2 basics

Paying for EC2

EC2 in depth

More compute

Which compute service for which job?

  • Lift an existing server to AWS as it is, or full control of the OS is needed → EC2.
  • A standard web app, and the team doesn't want to manage servers → Elastic Beanstalk.
  • Microservices packaged as containers → ECS or EKS, on Fargate if no servers are wanted.
  • Short tasks triggered by events (a file upload, an API call, a message) → Lambda.
  • Large batch jobs that run for hours, such as nightly reports or simulations → AWS Batch.
  • Must run in the customer's own data centre with AWS APIs → AWS Outposts.

Exam tips

  • "Least operational overhead" usually rules EC2 out when a managed option works: Beanstalk, Fargate or Lambda.
  • "Full control of the operating system", "specific licensing", "custom kernel" → EC2.
  • "Runs longer than Lambda's limit", "needs a GPU", "any runtime in a Docker image" → Batch, ECS or EC2, not Lambda.
  • "Lowest cost for fault-tolerant work" → Spot Instances, often through Batch or an Auto Scaling group.

AWS documentation

On this page

Open notes

Spotted a mistake?

These notes are open source. Suggest a fix, or star the repo if they helped you.

Suggest an edit

For AI agents: llms.txt · llms-full.txt