PlayCloudLabs
Sign in
  1. Learn
  2. AWS
  3. Compute
  4. EC2
AWSGCP laterAzure later

EC2Amazon Elastic Compute Cloud

ComputeCore service · full depthChecked against AWS docs · 15 Sept 2026

Virtual machines you choose, size and run yourself: the most flexible compute on AWS, and the most work.

Where EC2 takes you7 steps, all open

  1. I know the problem it solves
  2. I can picture it
  3. I know how it scales
  4. I know how it fails
  5. I know when to choose it
  6. I can use it in a design
  7. I can answer an exam question

What & why

A whole machine, when nothing less will do

EC2 gives you virtual machines, called instances. You choose the image it boots, an AMI; the instance type, which sets its CPU, memory, storage and network; the subnet it runs in; and where it keeps its data. After that, patching, sizing and scaling are yours.

It is the most flexible compute on AWS, and the most work. Reach for something more managed when you can, and for EC2 when you need what only a whole machine gives you.

Reach for it when

  • you need full control of the operating system
  • the software needs privileged access, such as a kernel driver of its own
  • a job runs longer than Lambda's 15-minute limit
  • licences are per socket or per core: Dedicated Hosts

It is the wrong tool when

  • short code runs in response to events: that is Lambda
  • you want to run containers without managing servers: that is Fargate
  • nobody wants to patch an operating system, and nothing needs one

Mental model

Renting a car

You pick a model and what comes with it, and pay by the second while you have it. Commit to a year or three and it costs less. Take a car from the spare pool and it is cheap, but the company can take it back with two minutes' warning. Anything left in the glovebox is gone when the car goes back; your luggage in a locker stays.

The model and its extrasthe operating system and softwareAMI
Engine and seatsCPU, memory, storage, networkInstance type
Paying as you gono commitmentOn-Demand
A long leasea 1 or 3 year commitmentSavings Plans
The spare poolcheap, can be taken backSpot
The gloveboxstorage that goes with the carInstance store

How it works

From an image to a running instance
  1. Choose an AMIThe operating system and software it boots. An AMI belongs to one Region, and can be copied to others.
  2. Choose a typeThe instance type sets the hardware: general purpose, compute, memory or storage optimised, or accelerated.
  3. Launch itInto a subnet, with security groups and an IAM role. It gets a private IPv4 address, and a public one if you ask.
  4. Keep the dataOn a persistent volume, or in S3 or EFS. Instance store is scratch space that is erased when the instance stops.
Billing
Per second60 s minimum; SUSE Linux by the hour
Spot interruption
2 minwarning, in metadata and EventBridge
Spread placement
≤ 7running instances per AZ
Partition placement
≤ 7partitions per AZ
Instance store
Lost on stopkept through a reboot
IMDSv2 token
≤ 6 hsession-oriented

Public IPv4 address

  • assigned from Amazon's pool, not yours
  • released when the instance stops, hibernates or terminates
  • a new one is assigned when it starts again

Elastic IP address

  • static, and yours until you release it
  • can be remapped to another instance to mask a failure
  • charged whether it is in use or idle, like every public IPv4 address

Architecture

Two zones behind a load balancer

Architecture

One instance in each Availability Zone, so losing a zone costs half the capacity, not the site.

One instance in each Availability Zone, so losing a zone costs half the capacity, not the site.

The load balancer sends requests only to healthy targets. With the default settings it checks each instance every 30 seconds and takes it out of service after two failures in a row, so an instance that dies stops getting traffic within about a minute.

Scaling

Up, or out

Up: change an instance's type for a bigger one. Out: add more instances behind a load balancer. Out is what survives a failure, and it is what Auto Scaling automates.

The numbers in this simulation are made up to show the shape, not the capacity of any real instance type.

Capacity: 500 requests a second for each.

200 requests a second more than 2 instances can take. Add 1 more, or shed the load.

Failure simulation

Lose an instance, then lose a zone

Both instances in AZ a

CustomersServed by Web 1 and Web 2

AZ a

AZ b

Click a node to make it fail. The timings in the log are the real ones, played 10× faster.

  1. Everything is up. Take a node or a whole zone down.

One instance in each zone

CustomersServed by Web 1 and Web 2

AZ a

AZ b

Click a node to make it fail. The timings in the log are the real ones, played 10× faster.

  1. Everything is up. Take a node or a whole zone down.

An instance lives in one Availability Zone. Put both in the same zone and losing it is an outage; spread them and it is lost capacity.

Its instance store is erased when the instance stops, so nothing you cannot lose belongs there. An Elastic IP address can be remapped to a replacement to mask a failure.

If every target fails its health checks at once, an Application Load Balancer sends traffic to all of them anyway, rather than to none.

Security

Credentials, metadata and the way in

A role, never keys. An instance gets temporary credentials from its IAM role, through an instance profile, and they are updated automatically. An instance has one role at a time.

Require IMDSv2. The instance metadata service is where those credentials come from. IMDSv2 makes every request start with a session token, which AWS recommends as defence in depth against open firewalls, reverse proxies and SSRF.

Security groups let in only what a rule allows: a new security group allows no inbound traffic at all.

No public address just to log in. EC2 Instance Connect Endpoint connects you to an instance from the internet without the instance having a public IPv4 address.

Cost

How you are charged, not what it costs today

By the second. Linux, Windows, RHEL and Ubuntu Pro instances are billed per second with a 60-second minimum; SUSE Linux Enterprise Server by the full hour.

Commit for less. Savings Plans commit to a consistent amount of spend per hour for 1 or 3 years, across instance types. Reserved Instances commit to one instance configuration for 1 or 3 years.

Spot uses spare capacity for much less, and can be interrupted with a two-minute warning.

Also on the bill: every public IPv4 address. Instance store is included in the instance's price.

Prices change, so none are printed here. Check the EC2 pricing pages on aws.amazon.com.

Comparison

Six ways to pay for the same instance
OptionYou commit toCan be interruptedChoose it when
On-DemandNothing; pay by the secondNoUsage is short, spiky or unknown
Savings PlansSpend per hour, for 1 or 3 yearsNoUsage is steady, but types and sizes change
Reserved InstancesOne configuration, for 1 or 3 yearsNoThe same instance runs all the time
Spot InstancesNothingYes, with a 2-minute warningWork that can stop and restart
Dedicated HostsA physical server of your ownNoPer-socket or per-core licences, or compliance
Capacity ReservationsCapacity in one Availability ZoneNoYou must be able to launch at a given moment

SAA traps

The phrase in the question, and what it means
fault-tolerant batch jobs, at the lowest costSpot Instances

The work can restart, so a two-minute interruption notice is acceptable.

steady usage, but the instance families keep changingA Savings Plan

It commits to spend per hour, not to one configuration.

software licensed per socket or per coreDedicated Hosts

A physical server of your own, so existing licences apply.

the lowest latency between the nodes of an HPC jobA cluster placement group

Close together in one Availability Zone, with the highest throughput between them.

a few critical instances must never share hardwareA spread placement group

Each on distinct hardware, up to seven running instances per zone.

HDFS or Cassandra nodes across separate racksA partition placement group

Partitions do not share racks, and the application can see which is where.

the data on the instance store was gone after a stopInstance store is temporary

It survives a reboot, not a stop. Keep data on a persistent volume or in S3.

the public IP changed after the instance was restartedAn Elastic IP address

A public IPv4 address is released on stop; an Elastic IP address stays yours.

Scenario

Exam style, marked when you answer

A company runs a nightly analytics job on EC2 that takes about four hours. It saves checkpoints, so if it is interrupted it can resume where it stopped. The finance team wants it to cost as little as possible. Which purchasing option should a solutions architect choose?

Practice

Fill the gap, the way the challenges work

A vendor's image analysis software installs its own kernel driver, and each job runs for up to six hours. Jobs arrive on a queue, and results are written to S3. What runs the software?

SQS· Job queuePick a service belowS3· Results

Quick revision

The night before the exam
Billing
Per second, 60 s minimum; SUSE Linux by the hour.
Spot
Spare capacity for much less, with a two-minute warning.
Savings Plans or RIs
Commit to spend per hour, or to one configuration, for 1 or 3 years.
Placement groups
Cluster: one AZ, low latency. Partition: separate racks. Spread: up to 7 per AZ.
Instance store
Survives a reboot, not a stop.
Public IP
Changes on stop and start; an Elastic IP address does not.
Credentials
A role through an instance profile, with IMDSv2 required.

Next: Auto ScalingKeeps the right number of EC2 instances running. It replaces the ones that fail, and adds or removes instances as the load changes.

Open Auto Scaling

Checked against

Every fact on this page was checked against AWS’s own documentation on 15 Sept 2026. If AWS has changed something since, its page is the one to trust.

Still there?

You have been away for a while. We have saved what you were working on in this browser. In 60 seconds you will be signed out to keep your account safe.