Right-Sizing for Success: Selecting AWS Instance Sizes and Families
Selecting the appropriate instance size for a workload
Right-Sizing for Success: Selecting AWS Instance Sizes and Families
Determining the correct instance size and family is a critical skill for a Solutions Architect. It ensures that applications perform optimally while maintaining cost efficiency by avoiding over-provisioning.
Learning Objectives
After studying this guide, you should be able to:
- Identify the five primary EC2 instance families and their target workloads.
- Differentiate between vertical and horizontal scaling and when to apply each.
- Analyze workload metrics (CPU, RAM, I/O) to select an appropriate instance size.
- Utilize AWS Compute Optimizer to refine resource allocation based on historical data.
- Execute the steps required to change an instance type for an existing workload.
Key Terms & Glossary
- vCPU (Virtual CPU): A unit of compute power representing a portion of the physical CPU thread.
- ECU (EC2 Compute Unit): A relative measure used by AWS to compare the integer processing power of different instance types.
- Instance Family: A grouping of instances optimized for specific tasks (e.g., C-series for Compute, R-series for Memory).
- Vertical Scaling: Increasing the capacity of a single resource (e.g., resizing an
m5.largeto anm5.4xlarge). - Horizontal Scaling: Adding more resources of the same size to a pool (e.g., adding three more
t3.microinstances via an Auto Scaling Group). - EBS-Optimized: An instance configuration that provides dedicated throughput between Amazon EC2 and Amazon EBS.
The "Big Idea"
The core philosophy of AWS compute is Matching Resources to Demand. Unlike on-premises environments where you must over-provision for peak capacity years in advance, the cloud allows for "Right-Sizing." The goal is to select an instance that meets the performance requirements of the workload with the least amount of wasted overhead, utilizing tools like CloudWatch and Compute Optimizer to continuously iterate on that selection.
Formula / Concept Box
| Parameter | Impact on Performance | Metric to Monitor |
|---|---|---|
| vCPU / ECU | Determines how many concurrent threads/processes can run. | CPU Utilization |
| Memory (RAM) | Critical for databases, caches, and high-performance analytics. | Memory Utilization (via CloudWatch Agent) |
| Network Bandwidth | Affects data transfer speeds between instances and services. | Network In / Network Out |
| EBS Throughput | Determines how fast data can be read from or written to block storage. | EBS Read/Write Ops |
Hierarchical Outline
- I. Understanding Instance Families
- General Purpose (M, T, A): Balanced resources for web servers and small databases.
- Compute Optimized (C): High-performance processors for batch processing and media encoding.
- Memory Optimized (R, X, Z): High RAM-to-CPU ratio for high-performance databases and in-memory caches.
- Storage Optimized (I, D, H): High local storage throughput for NoSQL databases and data warehousing.
- Accelerated Computing (P, G, F): Hardware accelerators (GPUs/FPGAs) for ML and graphics.
- II. Sizing Strategies
- The Sizing Naming Convention:
[Family][Generation].[Size](e.g.,m5.large). - Resource Doubling: In most families, moving up one size (e.g., from
largetoxlarge) exactly doubles the vCPU and RAM.
- The Sizing Naming Convention:
- III. Operationalizing Selection
- Metric Analysis: Use CloudWatch to identify bottlenecks.
- AWS Compute Optimizer: Uses machine learning to recommend optimal types based on 14 days of history.
- Changing Instance Types: Requires stopping the instance (for EBS-backed instances), changing the type, and restarting.
Visual Anchors
Instance Selection Decision Tree
Scaling Visualized
\begin{tikzpicture} % Vertical Scaling \draw[thick, fill=blue!10] (0,0) rectangle (1,1) node[midway] {\tiny m5.large}; \draw[->, thick] (0.5, 1.2) -- (0.5, 1.8) node[midway, right] {Scale Up}; \draw[thick, fill=blue!30] (0,2) rectangle (1.5,3.5) node[midway] {m5.4xlarge}; \node at (0.75, -0.5) {Vertical Scaling};
% Horizontal Scaling \draw[thick, fill=green!10] (4,0) rectangle (5,1) node[midway] {\tiny t3.micro}; \draw[->, thick] (5.2, 0.5) -- (5.8, 0.5) node[midway, above] {Scale Out}; \draw[thick, fill=green!10] (6,0) rectangle (7,1) node[midway] {\tiny t3.micro}; \draw[thick, fill=green!10] (7.2,0) rectangle (8.2,1) node[midway] {\tiny t3.micro}; \draw[thick, fill=green!10] (8.4,0) rectangle (9.4,1) node[midway] {\tiny t3.micro}; \node at (6.7, -0.5) {Horizontal Scaling}; \end{tikzpicture}
Definition-Example Pairs
- Burstable Performance Instances (T-series): Instances that provide a baseline level of CPU performance with the ability to burst above that baseline when needed.
- Example: A low-traffic microservice that stays idle most of the day but needs high CPU for 5 minutes during a morning data sync.
- Compute Intensive Workload: Tasks that require high integer or floating-point math operations relative to memory usage.
- Example: A video transcoding server that converts raw footage into different formats (MP4, MKV).
- Memory Intensive Workload: Applications that process large datasets in RAM to avoid slow disk I/O.
- Example: A Redis cluster used for session management in a high-traffic web application.
Worked Examples
Scenario: Resizing an Over-provisioned Server
Problem: You are running an application on an m5.4xlarge (16 vCPU, 64 GiB RAM). CloudWatch metrics show that over the last 30 days, CPU utilization never exceeded 10%, and Memory utilization peaked at 15 GiB.
Step-by-Step Solution:
- Identify the Bottleneck: The current server is significantly under-utilized.
- Analyze Requirements: Peak memory is 15 GiB. The closest smaller size in the M5 family that accommodates this is
m5.large(2 vCPU, 8 GiB RAM - too small) orm5.xlarge(4 vCPU, 16 GiB RAM). - Select New Size: Choose
m5.xlarge. This reduces costs by roughly 75% while still meeting peak memory needs. - Execution Path:
- Stop the EC2 instance.
- Select Actions > Instance Settings > Change Instance Type.
- Select
m5.xlargefrom the dropdown. - Start the instance.
Checkpoint Questions
- Which instance family is most appropriate for a high-performance relational database like MySQL or PostgreSQL?
- True or False: You can change the instance type of an EC2 instance while it is in the "Running" state.
- What service should you consult if you want automated recommendations for right-sizing your instances?
- If an instance's name is
c6g.2xlarge, what does the "g" signify? - Explain the difference between horizontal and vertical scaling in terms of application availability.
▶Click to see Answers
- R-series (Memory Optimized) is typically best for relational databases.
- False. For EBS-backed instances, the instance must be stopped before changing the type.
- AWS Compute Optimizer.
- It signifies the instance uses AWS Graviton (Arm-based) processors.
- Horizontal scaling increases availability (if one instance fails, others remain), whereas vertical scaling usually involves downtime during the resize and remains a single point of failure.