Skip to main content

Amazon EC2

  • What it is
    • Elastic Compute Cloud — resizable virtual machines (instances) in AWS. The baseline compute service everything else abstracts away.
    • You control the OS, networking, storage, and everything on the instance; AWS manages the physical host.
  • Pay only for what you run
    • Billed per second (Linux) or per hour, only while the instance runs. Stop it and compute charges stop.
    • Commercial terms are a separate axis — see Instance Pricing Options (On-Demand, Reserved, Spot, etc.).

Anatomy of an instance

  • Amazon Machine Image (AMI) — the template: OS, software, and config the instance boots from.
  • Instance type — the hardware profile (vCPU, memory, network, GPU). Format family.generation.size, e.g. t3.micro.
  • StorageAmazon Elastic Block Store (EBS) volumes (persistent, network-attached) and/or EC2 Instance store (ephemeral, physically attached, wiped on stop).
  • Networking — lives in an Amazon VPC subnet; a security group is the instance’s stateful firewall.
  • Key pair — SSH/RDP credentials (or skip keys entirely with Session Manager).
  • User data — a bootstrap script run once at first launch to install/configure software.

Instance families

Chosen by the bottleneck of your workload:

Lifecycle

  • Running → Stopped — EBS-backed instance shuts down, EBS data persists, no compute charge; instance-store data is lost.
  • Stopped → Started — usually lands on different host hardware; public IP changes unless an Elastic IP is attached.
  • Terminated — instance deleted; root EBS volume deleted by default.
  • Reboot — same host, IPs and instance-store data preserved.

Scaling and availability

  • EC2 Auto Scaling — an Auto Scaling Group adds/removes instances to match demand and replaces unhealthy ones. Horizontal scaling.
  • Vertical scaling = resize to a bigger instance type; requires a stop/start.
  • Spread instances across multiple Availability Zones behind a load balancer for high availability.
  • Amazon EC2 Fleet — provision a mixed group across instance types, AZs, and purchase options in one API call.

Shared responsibility

  • AWS — the hypervisor, host hardware, physical security, network infrastructure.
  • You — guest OS patching, software, security group rules, IAM, and data on the instance.

Not to be confused with

  • Amazon Lightsail — bundled EC2 at a fixed monthly price, knobs hidden; EC2 is the full-control version.
  • AWS Lambda / AWS Fargate — serverless compute with no instance to manage; EC2 is you managing the server.

Linked from