What AWS EC2 Instances Should You Use?

Amazon Elastic Compute Cloud (EC2) provides scalable computing capacity in the AWS cloud. With such a wide variety of EC2 instances available, how do you select the right one for your applications? In this comprehensive guide, we‘ll explore the key EC2 instance options so you can make informed decisions when deploying workloads on AWS.

Overview of AWS EC2 Instance Types

AWS offers over 50 EC2 instance types optimized for different use cases. At a high-level, they fall into these categories:

General Purpose Instances

General purpose instances provide balanced compute, memory and networking resources for a broad range of workloads. Key features include:

  • EBS optimization for improved I/O performance
  • Networking up to 25 Gbps bandwidth
  • Powered by AWS Nitro system

Use cases: Web servers, code repositories, development environments

Key instance families: A1, T3, T3a, T4g

Compute Optimized Instances

Compute optimized instances feature high performance processors ideal for compute intensive applications. Key features:

  • Cutting edge AWS Graviton2 processors
  • Up to 100 Gbps network bandwidth
  • EBS optimization

Use cases: Batch processing, media transcoding, high perfomance computing, gaming servers, ML inference

Key instance families: C5, C5a, C6g

Memory Optimized Instances

Memory optimized instances deliver fast performance for workloads that process large datasets in memory.

  • High memory size up to 24TB
  • Up to 100 Gbps network bandwidth
  • EBS optimization

Use cases: High performance databases, distributed web scale in-memory caches

Key instance families: R5, R5b, R6g

Storage Optimized Instances

Storage optimized instances allow applications to access very high, parallel local NVMe storage. Key features:

  • High sequential read/write capability
  • Millions of IOPS capability
  • Up to 16 TB NVMe SSD storage

Use cases: Large relational/NoSQL databases, data warehousing

Key instance families: I3, D2

Accelerated Computing Instances

Accelerated computing instances leverage GPUs and FPGAs for hardware based acceleration.

  • Industry leading GPUs like NVIDIA A100 Tensor Core
  • Programmable logic of FPGAs
  • Stream processing functionality

Use cases: Machine learning training/inference, speech recognition, finance analytics, genomics

Key instance families: P4, G5, F1

This covers the major EC2 instance categories available on AWS. Now let‘s look at the different instance sizes.

AWS EC2 Instance Sizes

In addition to the instance type denoting the hardware configuration, you also have to select the instance size which determines the compute, memory and storage resources allocated. Instance sizes range from nano to 32xlarge.

Some guidelines on choosing the size:

  • Nano – best for very light workloads like development environments
  • Micro/Small – well suited for websites with low traffic, staging environments
  • Medium – provides good balance for many applications including small databases, cache servers etc.
  • Large – good for high performance front end web/app servers
  • Xlarge – suited for demanding databases, in-memory caches, data analytics apps
  • 2xlarge – 32xlarge – ideal for large in-memory databases, business critical apps, batch processing

In general, you want to choose the lowest cost instance size that meets your performance requirements. Monitor resource utilization over time, and scale up or down as needed.

AWS EC2 Pricing and Cost Optimization

Understanding the AWS EC2 pricing model is key to cost optimization:

On Demand

Pay for compute capacity by the hour/second with no long term commitments. Simple but can be expensive for steady state workloads.

Reserved Instances

Make an upfront payment to receive a significant discount (up to 75%) compared to on-demand pricing. Best for steady state production workloads. 1 Year or 3 Year terms available.

Spot Instances

Bid for unused EC2 capacity and save up to 90% off on-demand pricing. Instances can be interrupted with 2 minute warning if your bid is below current spot price. Great cost savings but only suitable for fault tolerant workloads.

Dedicated Hosts

Physical servers dedicated for your use. Allows you to use existing per-socket, per-core, or per VM software licenses. More expensive but can cut licensing costs.

Savings Plans

Make a commitment to a consistent amount of usage, in USD per hour. Then receive discounted rates on that usage across a number of AWS services including EC2.

Best Practices for Cost Optimization:

  • Right size instances based on actual utilization metrics
  • Use auto-scaling groups and load balancers to match capacity to workload demand
  • Purchase Reserved Instances for steady state production workloads
  • Use Spot Instances for fault tolerant workloads like big data analytics
  • Enable CloudWatch alarms to notify you of high utilization
  • Implement start/stop schedules to automatically shutdown dev/test environments
  • Utilize AWS Savings Plans for predictable workloads

Following these best practices allows you to optimize cloud spend and reduce EC2 costs.

Recommendations for Selecting EC2 Instances

Here is a summary of key considerations when choosing AWS EC2 instances:

Application Requirements

Analyze workload performance, scalability and availability requirements. Review resource utilization metrics – CPU, memory, network, storage IOPS. These provide the basis for selecting instance type and size.

Instance Types

Choose the instance type optimized for your workload‘s dominant resource requirement – compute, memory, storage, GPU acceleration etc.

Instance Size

Right size the instance based on actual resource utilization data to minimize waste. Balance performance with cost.

Pricing Model

Use Reserved or Spot instances for production workloads to maximize savings over On-demand pricing.

Monitoring

Track utilization metrics with CloudWatch and scale instance size/count based on demand. Receive alerts on high utilization.

Example Configurations

Below are suggested EC2 configurations for some common workloads:

Web application servers – Application load balancer + Auto scaling group of T3 general purpose instances

In-memory cache – Multi-AZ Cluster with R5 memory optimized instances

NoSQL databases– R6g memory optimized instances

High performance computing – C6g compute optimized instances with placement groups and enhanced networking

Video encoding platform – P3 accelerated computing instances with GPU hardware acceleration

Each application has unique requirements that determine the optimal EC2 instance selection.

Conclusion

With such a wide variety of instance configurations, selecting the ideal AWS EC2 instances for your workloads can seem complex. This guide covers all the major instance types, sizes, pricing models and best practices to help you make great decisions. Matching instance specifications to your workload and scaling appropriately allows you to maximize performance and optimize cloud costs. Use the recommendations provided to select, size and configure EC2 instances tailored to your application‘s needs.