githubEdit

EC2

EC2

Introduction

Amazon Elastic Compute Cloud (EC2) is a core AWS service that provides resizable virtual servers (instances) in the cloud. EC2 offers a wide range of instance types optimized for different workloads, along with flexible pricing models, storage options, and networking configurations. It forms the foundation of most AWS infrastructure deployments.

Instance Types

EC2 instance types are grouped by family based on the target workload:

Family
Purpose
Example

t3/t4g

General purpose, burstable

Web servers, dev environments

m6i/m7g

General purpose, balanced

Application servers, databases

c6i/c7g

Compute optimized

Batch processing, ML inference

r6i/r7g

Memory optimized

In-memory caches, large databases

i4i

Storage optimized

High I/O databases

p4d/p5

GPU accelerated

ML training, HPC

g5

Graphics intensive

Video encoding, game streaming

Instance naming convention: <family><generation><attributes>.<size> (e.g., m6i.xlarge, c7g.2xlarge)

Pricing Models

  • On-Demand: Pay by the second with no commitment

  • Reserved Instances: 1 or 3-year commitment for up to 72% discount

  • Savings Plans: Flexible pricing with commitment to usage amount ($/hr)

  • Spot Instances: Up to 90% discount for interruptible workloads

  • Dedicated Hosts: Physical server dedicated to your account for compliance requirements

Key Concepts

AMI (Amazon Machine Image)

AMIs are templates for launching instances:

Security Groups

User Data (Instance Initialization)

Example init-script.sh:

Instance Lifecycle

EBS Volumes

Reference:

Last updated