AWS Compute Services

Amazon Elastic Compute Cloud (EC2)

7 min read
Updated June 21, 2025
7,687 characters

Core EC2 Components

Amazon Machine Image (AMI)

An AMI is a master template used to create a virtual server, known as an EC2 instance. It contains all the necessary information to launch an instance, including:

  • The operating system (Linux, Windows Server, etc.).
  • An initial software configuration (application servers, custom applications).
    -- Permissions that control which AWS accounts can use the AMI.
  • A block device mapping that specifies the volumes to attach to the instance upon launch.

You can select from pre-built AMIs provided by AWS, browse the AWS Marketplace for third-party AMIs, or create your own custom AMIs.

EC2 Instance Types

EC2 offers a vast selection of instance types optimized for different use cases. These are grouped into families based on their target workloads:

  • General Purpose: A balance of compute, memory, and networking resources. Ideal for a wide range of diverse workloads such as web servers and code repositories. (e.g., T and M families).
  • Compute Optimized: Designed for compute-intensive applications that benefit from high-performance processors, such as batch processing, media transcoding, and high-performance computing (HPC). (e.g., C family).
  • Memory Optimized: Ideal for workloads that process large data sets in memory, like high-performance databases, distributed web-scale caching, and real-time big data analytics. (e.g., R and X families).
  • Storage Optimized: Built for workloads requiring high, sequential read and write access to very large data sets on local storage, such as data warehousing and distributed file systems. (e.g., I and D families).
  • Accelerated Computing: Utilize hardware accelerators, or co-processors, to perform functions like floating-point number calculations, graphics processing, or data pattern matching more efficiently than is possible in software running on CPUs. (e.g., P, G, and F1 families).

EC2 Purchasing Options

Amazon EC2 provides several ways to pay for instances, allowing you to optimize your costs based on your usage patterns.

1. On-Demand Instances

  • Use Case: Pay for compute capacity by the hour or second with no long-term commitments. Perfect for applications with short-term, spiky, or unpredictable workloads that cannot be interrupted.
  • Flexibility: Provides the most flexibility, allowing you to increase or decrease capacity as needed.

2. Spot Instances

  • Use Case: Request spare EC2 computing capacity for up to a 90% discount compared to On-Demand prices. Ideal for fault-tolerant and flexible applications, such as big data analysis, containerized workloads, CI/CD, and web servers.
  • Mechanism: Spot Instances can be interrupted by AWS with a two-minute warning when EC2 needs the capacity back.

3. Reserved Instances (RIs)

  • Use Case: Provides a significant discount (up to 72%) compared to On-Demand pricing in exchange for a commitment to a specific instance family in a specific region for a one or three-year term. Best for applications with steady-state or predictable usage.
  • Types:
    • Standard RIs: Offer the highest discount but are locked to a specific instance family and size.
    • Convertible RIs: Provide a lower discount but allow you to change the instance family, OS, and tenancy during the term.

4. Savings Plans

  • Use Case: A flexible pricing model that offers lower prices in exchange for a commitment to a consistent amount of usage (measured in $/hour) for a one or three-year term.
  • Flexibility: Discounts automatically apply to EC2 instance usage regardless of instance family, size, OS, tenancy, or AWS Region. This provides more flexibility than RIs.

5. Dedicated Hosts

  • Use Case: A physical EC2 server dedicated for your use. Helps you address compliance requirements and reduce costs by allowing you to use your existing server-bound software licenses.

EC2 Storage Options

1. Elastic Block Store (EBS)

EBS provides persistent block-level storage volumes for use with EC2 instances. It is network-attached storage that persists independently from the life of an instance.

  • Persistence: Data remains even after the EC2 instance is stopped or terminated.
  • Volume Types:
    • General Purpose SSD (gp2/gp3): The default choice, balancing price and performance for a wide variety of workloads.
    • Provisioned IOPS SSD (io1/io2): High-performance volumes for mission-critical, I/O-intensive database and application workloads.
    • Throughput Optimized HDD (st1): Low-cost HDD volumes designed for frequently accessed, throughput-intensive workloads.
    • Cold HDD (sc1): The lowest-cost HDD volume for less frequently accessed data.

2. Instance Store

An instance store provides temporary, block-level storage for your instance. This storage is located on disks that are physically attached to the host computer.

  • Ephemeral: Data on an instance store volume persists only for the life of the associated instance. If you stop, hibernate, or terminate an instance, all data on its instance store is lost.
  • Performance: Offers very high IOPS, making it ideal for temporary storage of information that changes frequently, such as buffers, caches, or scratch data.

EC2 Networking and Security

  • Virtual Private Cloud (VPC): Your EC2 instances are launched within a logically isolated section of the AWS Cloud, giving you control over your virtual networking environment.
  • Security Groups: A virtual firewall for your instance to control inbound and outbound traffic. They are stateful, meaning if you allow inbound traffic, the corresponding outbound traffic is automatically allowed.
  • Elastic IP Addresses (EIPs): A static, public IPv4 address designed for dynamic cloud computing. You can mask the failure of an instance by rapidly remapping the address to another instance in your account.
  • Elastic Network Interfaces (ENIs): Virtual network cards that can be attached to an instance. You can create and attach multiple ENIs to an instance, enabling different network configurations.

Availability and Scalability

Placement Groups

Placement groups allow you to influence the placement of your EC2 instances to meet the needs of your workload.

  • Cluster Placement Group: Packs instances close together inside an Availability Zone. This strategy enables workloads to achieve the low-latency, high-throughput network performance required for HPC applications.
  • Spread Placement Group: Spreads your instances across distinct underlying hardware to reduce correlated failures. Recommended for applications that have a small number of critical instances that should be kept separate from each other.
  • Partition Placement Group: Spreads instances across logical partitions, ensuring that instances in one partition do not share underlying hardware with instances in other partitions. Useful for large distributed and replicated workloads, such as HDFS, HBase, and Cassandra.

EC2 Auto Scaling

EC2 Auto Scaling helps you maintain application availability and allows you to automatically add or remove EC2 instances according to conditions you define.


Special Features

EC2 Hibernation

When an EC2 instance is hibernated, AWS signals the operating system to perform hibernation (suspend-to-disk). The instance's in-memory state (RAM) is saved to a file on the root EBS volume. This allows you to stop and later resume your instance from its last state, which is much faster than a full reboot.