AWS · Compute

Amazon EC2

Resizable virtual servers in the cloud, with hundreds of instance types and several ways to pay: On-Demand, Savings Plans, Reserved and Spot.

On the SAA-C03 exam listAutomation

What it is and what problem it solves

Amazon EC2 (Elastic Compute Cloud) gives you virtual machines, called instances, that you start in minutes and pay for while they run. You choose an AMI (the operating system image), an instance type (the mix of CPU, memory, storage and networking), a subnet in a VPC, security groups, a key pair or Systems Manager access, an IAM role for permissions, and storage: EBS volumes that persist, or instance store disks that are fast but lost when the instance stops.

Instance families are named for what they favour: general purpose (M, T), compute optimised (C), memory optimised (R, X), storage optimised (I, D) and accelerated computing (P, G, Inf, Trn). Graviton (Arm) types often cost less for the same work.

more flexiblebigger discountOn-Demandno commitmentSavings Plans$/hour for 1 or 3 yrsReserved Inst.specific type, 1 or 3 yrsSpot≤90% off, interruptibleDedicated Hosts / Instancesfor licensing or compliance, not discountsOn-Demand Capacity Reservationsguaranteed capacity in an AZ, no discount
EC2 purchasing options: trade flexibility for discount

When to use it

  • You need full control of the operating system, runtime or networking.
  • Long-running or steady workloads, legacy applications and commercial software licensed per server.
  • Workloads needing special hardware: GPUs, very large memory, local NVMe, high network bandwidth.
  • As the capacity behind containers (ECS or EKS on EC2) when you want to manage the nodes.

When to avoid it

  • Event-driven or spiky short tasks: Lambda avoids paying for idle servers.
  • Containers without managing servers: Fargate.
  • Standard web apps where you would rather not manage the platform: Elastic Beanstalk or App Runner-style services, or containers on Fargate.
  • A single instance for something important: one instance in one zone is a single point of failure; use an Auto Scaling group across zones.

Scaling model and bottlenecks

Scale out with more instances in an Auto Scaling group behind a load balancer, which also gives resilience; scale up by changing to a larger instance type (a stop and start). Your account's On-Demand and Spot quotas are measured in vCPUs per instance family group, and new accounts start low, so request increases before large launches.

Performance, latency and throughput

Placement groups control how instances are placed: cluster packs them close in one zone for low-latency, high-throughput networking (HPC); spread puts each on separate hardware to limit correlated failures; partition spreads groups of instances across racks for large distributed systems (HDFS, Cassandra, Kafka). Enhanced networking (ENA) and EBS-optimised instances raise network and storage throughput.

Limits and quotas

ItemValueContextSource
On-Demand quota for standard instance families 5 vCPUs by default
Can be raised with a quota request
Quotas are counted in vCPUs per family group (A, C, D, H, I, M, R, T, Z share one); several accelerated and specialised families start at 0. Source
checked
Running instances per Availability Zone in a spread placement group 7 Rack-level spread placement groups. Source
checked
Partitions per Availability Zone in a partition placement group 7 Source
checked
Spot interruption notice 2 minutes before the instance is stopped or terminated Source
checked

Quotas and limits change. Check the linked source before designing around a number.

Cost model

What you pay for

  • Instances, billed per second with a 60-second minimum for Linux, Windows and several other operating systems, at a price set by type, Region and operating system.
  • Purchase options: On-Demand (no commitment), Savings Plans and Reserved Instances (1- or 3-year commitments for lower rates), Spot (spare capacity at a deep discount that can be interrupted), Dedicated Hosts and Capacity Reservations.
  • Attached resources: EBS volumes and snapshots, public IPv4 addresses, data transfer out and across zones, and licences.

Where it is cost-efficient

Steady baseline load on Savings Plans, fault-tolerant or flexible work (batch, CI, rendering) on Spot, and right-sized, current-generation (often Graviton) instance types.

Where costs grow

  • Instances left running when idle, oversized instance types, and unattached EBS volumes and old snapshots.
  • On-Demand for 24/7 workloads that could be committed.
  • Cross-zone and internet data transfer from chatty designs.

Cost controls and common surprises

Use Compute Optimizer for right-sizing, schedule non-production instances to stop out of hours, buy Savings Plans for the steady baseline, use Spot for interruptible work, and clean up volumes, snapshots and Elastic IPs.

Prices differ by Region and change over time; see the pricing page linked under Sources.

Security

Controls the service provides

  • Instances run inside your VPC behind security groups; the Nitro System isolates instances on shared hardware.
  • IAM roles (instance profiles) give applications temporary credentials; IMDSv2 protects the metadata service.
  • EBS encryption with KMS; Systems Manager Session Manager for access without SSH keys or open ports.

What you configure

Patch the operating system and software, require IMDSv2, avoid long-lived keys on instances, keep instances in private subnets where possible, use least-privilege roles, and encrypt EBS volumes by default.

Logging and monitoring

CloudWatch metrics and agent-collected logs, VPC Flow Logs, CloudTrail for API calls, Inspector for vulnerabilities, GuardDuty for threats.

Related security services

Systems Manager (patching, Session Manager), Inspector, GuardDuty, KMS, IAM.

Shared responsibility

AWS secures the hardware and hypervisor. You secure the guest operating system, software, network rules and data.

Availability, backup and failure behavior

An instance runs in one Availability Zone. Run instances in at least two zones behind a load balancer, in an Auto Scaling group that replaces failed instances. Use EBS snapshots or AWS Backup for data, and AMIs to rebuild servers quickly. Spot instances can be reclaimed with a two-minute notice, so use them only for work that can stop.

Common service combinations

Auto Scaling groups and Elastic Load Balancing; EBS, EFS and FSx for storage; Systems Manager for operations; CloudWatch for monitoring; Savings Plans for cost.

Business application examples

  • A web tier of instances across three zones behind an ALB, scaling with traffic.
  • A nightly rendering farm on Spot instances.
  • A commercial database licensed per core on a Dedicated Host.

Exam cues and common confusions

  • Purchase options: On-Demand (short, unpredictable), Savings Plans or Reserved (steady 1 or 3 years), Spot (interruptible, cheapest), Dedicated Hosts (per-socket or per-core licences, compliance).
  • Placement groups: cluster (low latency, one zone), spread (separate hardware, few critical instances), partition (large distributed systems).
  • Instance store is lost on stop; EBS persists.
  • Credentials for apps on EC2: an instance profile role, never stored keys.
  • Hibernate keeps memory state for faster restarts.

Related

Courses and lessons

Services, comparisons and patterns

Sources

Independent study material, not affiliated with or endorsed by Amazon Web Services. AWS and service names are trademarks of Amazon.com, Inc. or its affiliates.

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake