Amazon EC2: What It Is and When to Use It

Definition

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable, on-demand virtual servers — called instances — running in the AWS Cloud. You choose an instance type (CPU, memory, networking, storage) and an Amazon Machine Image (AMI) that bundles an operating system and any pre-installed software, and EC2 launches the server in minutes. You pay only for the compute time you use, with per-second billing (60-second minimum) and multiple ways to save for predictable workloads.

How It Works

An EC2 instance lives inside a Virtual Private Cloud (VPC), attached to a subnet in a specific Availability Zone. Key moving parts:

  • AMI (Amazon Machine Image) — the template for the instance: OS kernel, root filesystem, and any baked-in software. AWS provides Amazon Linux and Windows AMIs; the community and marketplace provide thousands more.
  • Instance type — the hardware profile (e.g., t3.medium = 2 vCPUs, 4 GB RAM, burstable CPU credits).
  • EBS volumes — persistent block storage attached over the network. EBS survives instance stop/start and can be snapshotted to S3.
  • Instance store — ephemeral local NVMe/SSD storage physically attached to the host. Fast, but data is lost on stop or hardware failure.
  • Security group — a stateful virtual firewall at the instance level that controls inbound and outbound traffic by protocol, port, and source.
  • Key pair — SSH (Linux) or RDP-password (Windows) credentials. AWS keeps the public key; you keep the private key.
  • User data — a bootstrap shell script or cloud-init config run on first boot; used for configuration management and auto-joining clusters.

When demand changes, an Auto Scaling Group (ASG) launches or terminates instances against a Launch Template to maintain a target capacity or track a CloudWatch metric. ASGs can span multiple Availability Zones and be placed behind an Application Load Balancer for highly available web tiers.

Key Features and Limits

  • Instance types — hundreds of options grouped into families optimized for different workloads (see table below).
  • vCPU-based quotas — EC2 quotas are expressed in vCPUs per instance-family class (e.g., Standard On-Demand, F-family Spot). The default On-Demand quota is 64 vCPUs per family class and must be raised through Service Quotas for production growth.
  • Placement Groups — Cluster (low latency in one AZ), Spread (hardware isolation across hosts), and Partition (for distributed stores like Cassandra or HDFS).
  • Nitro System — AWS's modern hypervisor platform that offloads virtualization to dedicated hardware, delivering near-bare-metal performance and enabling features like Elastic Fabric Adapter (EFA) and Nitro Enclaves.
  • Graviton processors — AWS-designed Arm cores (found in instance families ending in g, such as m7g, c7g, r7g) typically offer 20–40% better price-performance than comparable x86 instances.
  • Networking — up to 400 Gbps on the largest instance sizes; enhanced networking via ENA and SR-IOV; Elastic IP for static public addresses.
  • Integration — IAM roles attached via Instance Profiles, CloudWatch metrics/alarms, Systems Manager Session Manager for keyless shell access, AWS Backup, and more.

Instance Family Cheat Sheet

| Family (letter) | Category | Example Workloads | | --- | --- | --- | | T, M, A, Mac | General Purpose | Web servers, microservices, small DBs | | C | Compute Optimized | CPU-heavy batch, gaming servers, HPC | | R, X, u-* (High Memory) | Memory Optimized | In-memory DBs, caches, SAP HANA | | I, D, H | Storage Optimized | NoSQL DBs, data warehouses, big sequential I/O | | P, G, Inf, Trn, F, VT | Accelerated Computing | ML training/inference, graphics, FPGA workloads |

Common Use Cases

  1. Web and application servers — the classic three-tier web app behind an Application Load Balancer with an Auto Scaling Group.
  2. Enterprise applications — SAP, Oracle, Microsoft SQL Server, Active Directory — often on memory-optimized or dedicated-host instances for licensing reasons.
  3. High-performance computing (HPC) — scientific simulations and engineering workloads using C-family instances with Elastic Fabric Adapter.
  4. Machine learning training and inference — P-family (GPUs) and Trn/Inf (Trainium/Inferentia) instances for custom model training outside of SageMaker or Bedrock.
  5. Game servers and real-time services — low-latency workloads that need custom kernels, local NVMe storage, or specific instance placement.
  6. Lift-and-shift migrations — existing VMs moved to EC2 via AWS Application Migration Service (MGN) before gradually modernizing.

Pricing Model

EC2 offers six pricing options, each tuned to a different commitment/flexibility trade-off:

  1. On-Demand — pay per second (or hour for Windows < 1 min) with no commitment. Best for unpredictable workloads or short-term testing.
  2. Savings Plans — commit to a $/hour spend for 1 or 3 years. Compute Savings Plans cover EC2, Fargate, and Lambda across any region/family (up to 66% off). EC2 Instance Savings Plans require a specific family in a region (up to 72% off).
  3. Reserved Instances (RIs) — commit to a specific instance family in a region (Regional) or AZ (Zonal) for 1 or 3 years. Up to 72% off Standard, 54% off Convertible. Being gradually replaced by Savings Plans for most use cases.
  4. Spot Instances — bid on unused EC2 capacity for up to 90% off On-Demand. AWS can reclaim capacity with a 2-minute warning. Ideal for fault-tolerant workloads: batch jobs, CI/CD runners, Kubernetes worker nodes with proper pod disruption budgets.
  5. Dedicated Hosts — a fully dedicated physical server, billed hourly or via a Savings Plan. Required for BYOL (Bring Your Own License) scenarios with per-socket or per-core Windows/Oracle licensing.
  6. Capacity Reservations — reserve capacity in a specific AZ without a pricing commitment; useful for DR or to guarantee capacity during regional demand spikes.

Beyond compute, EC2 bills you for attached EBS volumes, public IPv4 addresses (now charged as of Feb 2024), data transfer out of AWS, and NAT Gateway usage for private-subnet egress.

Pros and Cons

Pros

  • Full OS-level control — install any software, mount any filesystem, run any workload.
  • The broadest instance catalog in the industry, including specialized hardware (GPUs, FPGAs, Trainium).
  • Deep pricing flexibility: Spot and Savings Plans can drop TCO dramatically for the right workloads.
  • Mature, battle-tested; foundational to nearly every AWS architecture.

Cons

  • You are responsible for OS patching, hardening, and runtime management (Systems Manager Patch Manager and SSM Automation help).
  • Capacity planning, auto scaling rules, and load balancing need to be designed and tested — unlike Lambda or Fargate, there is no automatic scale-to-zero.
  • Complicated price-optimization landscape (On-Demand vs Spot vs RI vs Savings Plans vs Dedicated Hosts) requires deliberate governance.

Comparison with Alternatives

| | EC2 | Lambda | Fargate | | --- | --- | --- | --- | | Abstraction | VMs | Functions | Container tasks | | Max runtime | Unlimited | 15 min per invocation | Unlimited | | OS control | Full | None | Limited (container image) | | Scale-to-zero | No (without ASG tricks) | Yes | Yes | | Cold starts | Instance launch (~30–60 s) | 100 ms–few s (SnapStart/Provisioned Concurrency reduce) | Task launch (~30–90 s) | | Best for | Long-running servers, legacy apps, HPC | Short event-driven code | Stateless container workloads without node management |

Compared with Google Compute Engine and Azure Virtual Machines, EC2 is generally considered the most mature, with the widest region footprint and the broadest instance catalog.

Exam Relevance

EC2 shows up on virtually every AWS exam:

  • Cloud Practitioner (CLF-C02) — pricing options, instance basics, shared responsibility for EC2.
  • Solutions Architect Associate (SAA-C03) — choosing the right instance family, placement groups, Auto Scaling, Spot vs On-Demand decisions, mixed-instance ASGs, EC2-level DR.
  • Developer Associate (DVA-C02) — User Data, IAM instance profiles, CloudWatch agent, instance metadata service (IMDSv2).
  • SysOps Administrator (SOA-C02) — AMI lifecycle, patch management via SSM, instance troubleshooting, EBS volume performance tuning.
  • SAP, DOP, SCS — Nitro Enclaves, hybrid workloads with Outposts, Spot management at scale.

A frequent exam trap: Spot Instances have a 2-minute interruption notice and are unsuitable for workloads with long checkpoints — if a question emphasizes cost and fault tolerance, Spot is usually right; if it emphasizes uninterrupted long runs, On-Demand or RI is the answer.

Frequently Asked Questions

Q: What is the difference between EC2 stop, hibernate, and terminate?

A: Stop shuts down the OS and keeps the EBS root volume intact — you stop paying for compute, but you still pay for storage. Hibernate preserves the in-memory state to EBS so the instance resumes where it left off. Terminate permanently deletes the instance and (by default) its root EBS volume, which cannot be recovered.

Q: When should I choose Spot Instances over On-Demand?

A: Use Spot when your workload can tolerate interruption with a 2-minute notice — examples include batch processing, CI/CD runners, analytics clusters, and stateless Kubernetes worker nodes with proper pod disruption handling. For customer-facing services or long-running jobs without checkpointing, stick with On-Demand, Savings Plans, or Reserved Instances.

Q: How is EC2 different from AWS Lambda?

A: EC2 gives you full virtual machines that run continuously (you manage the OS, scaling, and patching), whereas Lambda runs short bursts of code triggered by events with no server management and automatic scaling. Pick EC2 when you need long-running processes, custom OS configurations, or legacy applications; pick Lambda when you need quick, event-driven code without worrying about servers.


This article reflects AWS features and pricing as of 2026. AWS services evolve rapidly — always verify against the official Amazon EC2 documentation before making production decisions.

Published: 4/16/2026 / Updated: 4/16/2026

This article is for informational purposes only. AWS services, pricing, and features change frequently — always verify details against the official AWS documentation before making production decisions.

More in Compute