SynfraCore
Synfracore
Start Learning
Navigation

Academies

Platform

RoadmapsLabsCertificationsInterviewPYQsAI AssistantCareer
Start Learning Free Learning Roadmaps

EC2 β€” Overview

What it is, why it matters, architecture and key concepts

πŸ“„
Last updated Aug 2026
Expert Content

AWS EC2 β€” Elastic Compute Cloud

Before you start: basic AWS familiarity (Regions, AZs, IAM roles) is assumed β€” see the AWS Core Services Overview and IAM courses first if those are new. No prior virtual-machine administration experience is needed.

EC2 is the backbone of AWS compute. It gives you virtual machines (instances) in the cloud that you can provision in minutes, scale automatically, and pay for only what you use.

What is EC2?

Amazon EC2 (Elastic Compute Cloud) provides resizable compute capacity in the cloud. An EC2 instance is essentially a virtual machine running on AWS infrastructure, but with cloud-native superpowers: auto-scaling, spot pricing, placement groups, elastic IPs, and deep integration with every other AWS service.

Analogy β€” Think of EC2 like renting a car instead of buying one. Buying a server (on-prem hardware) means paying the full price up front, maintaining it yourself, and being stuck with its capacity even when you don't need it. Renting from EC2's "car lot" means you pick the size you need right now (a t3.medium for a quick errand, an r6i.4xlarge for hauling a database), return it the moment you're done (stop or terminate the instance, stop paying for compute), and can swap to a bigger or smaller model tomorrow without buying new hardware. AWS owns and maintains the physical fleet; you just check out what you need, when you need it.

Try it (2 minutes) β€” Reason through EC2's stop-vs-terminate distinction without needing console access: if you stop an instance overnight and start it again in the morning, its EBS root volume (and therefore your installed software and files) survives β€” you're just not billed for compute while it's off. If you terminate it instead, that same volume is gone by default. Now ask yourself: if you were running a nightly batch job that only needs to exist for 10 minutes a day, would stopping or terminating the instance between runs be the cheaper, safer choice β€” and why does the answer change if the instance also holds data nothing else has a copy of?

Instance Types

EC2 has hundreds of instance types organized into families (needs verification β€” exact current count grows regularly as AWS releases new generations):

FamilyOptimized ForExampleUse Case

|--------|--------------|---------|----------|

**t3/t4g**General (burstable)t3.mediumDev/test, small web apps
m6i/m7iGeneral balancedm6i.xlargeWeb servers, app servers
c6i/c7iComputec6i.2xlargeCI/CD, batch, web frontends
r6i/r7iMemoryr6i.4xlargeDatabases, in-memory cache
i3/i4iStorage (NVMe)i3.xlargeHigh I/O databases
p3/p4dGPUp3.2xlargeML training, graphics
g4dn/g5GPU (inference)g4dn.xlargeML inference, video

Naming convention: c6i.2xlarge

β€’c = compute optimized family
β€’6 = 6th generation
β€’i = Intel processor (a = AMD, g = Graviton/ARM)
β€’2xlarge = size (8 vCPU, 16 GB RAM)

EC2 Pricing Models

ModelSavings vs On-DemandCommitmentBest For

|-------|---------------------|------------|----------|

**On-Demand**0% (baseline)NoneUnpredictable, short-term
Reserved (1yr)~40%1 yearSteady-state workloads
Reserved (3yr)~60%3 yearsLong-term stable workloads
Savings Plans~40-60%1 or 3 yearsFlexible (compute or EC2)
Spot~70-90%None (interruptible)Batch jobs, stateless apps
Dedicated Hostβ€” (premium)On-demand or reservedLicensing, compliance

πŸ’‘ FinOps tip: Use Reserved Instances or Savings Plans for your baseline, Spot for burst/batch. Never run all On-Demand in production.

Core Concepts

AMI
Template: OS + pre-installed software + config. Custom AMIs can be created from running instances
Security Groups
Stateful instance-level firewall. Allow-only rules, changes apply immediately
Key Pairs
SSH public/private key for Linux access. Lose the private key, lose SSH access
Elastic IP
Static IPv4 that persists across stop/start, unlike the default public IP

AMI (Amazon Machine Image) β€” Template containing OS, pre-installed software, and configuration. AWS provides official AMIs (Amazon Linux 2023, Ubuntu, Windows Server). You can create custom AMIs from running instances.

Security Groups β€” Stateful virtual firewall at the instance level. Rules are allow-only (no explicit deny). Inbound and outbound rules control traffic. Changes apply immediately.

Key Pairs β€” SSH public/private key pair for Linux instance access. AWS stores the public key, you keep the private (.pem) file. If you lose it, you can't SSH in.

Elastic IP β€” Static IPv4 address for your account. Instances get public IPs by default but they change on stop/start. Elastic IPs persist. Free when attached to running instance, charged when unattached.

User Data β€” Shell script or cloud-init that runs once when instance first boots. Use it to install packages, configure the instance, download code.

Instance Lifecycle

Launch
AMI + instance type chosen
Pending
AWS provisions the instance
Running
Billed for compute, can SSH in
Stopped
No compute bill, EBS storage still billed
Terminated
Permanently deleted, cannot recover
β€’Running β€” Billed for compute, can SSH in
β€’Stopped β€” Not billed for compute (still billed for EBS storage)
β€’Terminated β€” Permanently deleted, cannot recover
Share:
Join our Community
Daily tips, job alerts, interview help β€” join engineers learning together
β†’
Up Next
βš™οΈ
EC2 β€” Installation
Step-by-step setup and installation guide
Also Worth Exploring
← Back to all EC2 modules
Prerequisites β†’