Compute
EC2 fundamentals
Amazon Elastic Compute Cloud (EC2) provides virtual servers — instances. Even in a serverless world, EC2 underpins many services and appears throughout the exam, especially in performance and cost questions.
Instances, AMIs and launching
- An Amazon Machine Image (AMI) is the template: OS, software, configuration. Use AWS, Marketplace or your own custom (golden) AMIs for faster, consistent launches.
- AMIs are Regional — copy them to other Regions for DR or expansion.
- Launch templates capture instance settings (AMI, type, network, IAM role, user data) for reuse by Auto Scaling.
- User data runs scripts at first boot (install software, pull config).
- Instance metadata service (IMDS) at
169.254.169.254provides instance information and role credentials. Require IMDSv2 (session-based) for security.
Instance families
Instance type names look like m7g.large: family (m), generation (7), attributes (g = Graviton/ARM), size (large).
| Family | Optimised for | Examples of use |
|---|---|---|
| General purpose (M, T) | Balanced CPU/memory | Web servers, small databases; T = burstable CPU credits for spiky low-average load |
| Compute optimized (C) | High CPU per GB | Batch processing, media transcoding, high-performance web servers, gaming, scientific modelling |
| Memory optimized (R, X, z) | Large RAM | In-memory databases and caches, real-time big data analytics |
| Storage optimized (I, D, H) | High local disk throughput/IOPS | NoSQL databases, data warehousing, search, local caches |
| Accelerated computing (P, G, Inf, Trn, F) | GPUs and ML chips | ML training/inference, graphics rendering |
| HPC optimized (Hpc) | Tightly coupled HPC | Weather, simulations |
Tip
Graviton (ARM-based) instances often give better price-performance for compatible workloads — a common "cost-optimized" answer when the software supports ARM.
Scaling an instance
- Vertical scaling — change to a larger instance type (stop, change type, start). Has an upper limit and causes downtime for a single instance.
- Horizontal scaling — add more instances behind a load balancer. Preferred for availability and elasticity.
Instance storage
| EBS volume | Instance store | |
|---|---|---|
| Persistence | Survives stop/start and instance failure (independent lifecycle) | Lost on stop, hibernate, terminate or hardware failure |
| Location | Network-attached, in one AZ | Physically attached disks |
| Performance | Up to very high IOPS with io2 | Very high IOPS and throughput |
| Use | Boot volumes, databases, durable data | Caches, buffers, scratch data, replicated data |
Details in block and file storage.
Instance lifecycle
- Stop/start — EBS-backed instances keep their EBS volumes; usually move to new hardware; public IPv4 changes (unless Elastic IP).
- Hibernate — saves RAM contents to the (encrypted) EBS root volume; on start, the instance resumes where it left off. Faster start for apps with long initialisation. Requirements include an encrypted root volume large enough for RAM; hibernation is limited in duration (up to 60 days) and to supported instance types.
- Terminate — instance is deleted; root EBS volume deleted by default (configurable).
Tenancy and hardware
- Shared (default) — instances run on hardware shared with other customers (isolated by the Nitro hypervisor).
- Dedicated Instances — hardware dedicated to your account.
- Dedicated Hosts — a whole physical server you control; visibility of sockets/cores for bring-your-own-licence software licensed per socket/core, and for compliance needs.
EC2 networking essentials
- Each instance has a primary ENI; add more ENIs (e.g. a management network or failover by moving the ENI).
- Elastic IPs give a static public IPv4 address (charged; all public IPv4 addresses now incur hourly charges).
- Placement groups and enhanced networking — see network performance.
Monitoring EC2
- Default CloudWatch metrics every 5 minutes (CPU, network, disk I/O for instance store); detailed monitoring = 1-minute.
- Memory and disk space usage are not collected by default — install the CloudWatch agent.
- Status checks (system and instance) can trigger alarms that recover or reboot the instance automatically.
Exam patterns
- "An in-memory cache needs large RAM" → memory optimized (R family).
- "CPU-heavy video encoding" → compute optimized (C family).
- "Software licensed per physical core" → Dedicated Host.
- "An app takes 10 minutes to warm up; reduce start time when scaling" → hibernation, warm pools or pre-baked AMIs.
- "Need memory utilisation metrics" → CloudWatch agent.