Complete Interactive Guide to EC2, Containers, and Serverless Computing
Applications require Compute, Storage, and Network resources. AWS offers a comprehensive portfolio of compute services that can be broadly classified into categories based on their operational models.
| Service Category | Management Level | Use Case | Learning Curve | Cost Model |
|---|---|---|---|---|
| IaaS (EC2) | Full server control | Custom applications, legacy systems | Moderate to High | Pay for instance hours |
| PaaS (Elastic Beanstalk) | Platform managed | Web applications, rapid deployment | Low to Moderate | Pay for underlying resources |
| Containers (ECS/EKS) | Container orchestration | Microservices, modern applications | Moderate to High | Pay for compute + orchestration |
| Serverless (Lambda) | Function managed | Event-driven, short-running tasks | Low | Pay per execution |
Yes: Consider EC2 (IaaS)
No: Continue to step 2
Yes: Consider Lambda (Serverless)
No: Continue to step 3
Yes: Consider ECS/EKS (Containers)
No: Consider Elastic Beanstalk (PaaS)
Amazon Elastic Compute Cloud (EC2) is AWS's foundational Infrastructure as a Service (IaaS) offering, providing resizable virtual compute capacity in the cloud. EC2 uses Type 1 virtualization (bare-metal hypervisor) for optimal performance.
As announced in Werner Vogels' blog, EC2-Classic was officially retired on August 15, 2022. All instances now launch in VPC (Virtual Private Cloud) by default, providing enhanced security and networking capabilities.
Default Option - Most cost-effective
Hardware Isolation - Single customer hardware
Full Server Control - Entire physical server
Direct Hardware Access - No hypervisor
A template containing the operating system, pre-installed software, and configurations. Think of it as a "golden image" for launching instances.
Defines the hardware specifications including CPU, RAM, network performance, and storage options.
Understanding EC2 instance families is crucial for selecting the right compute resources for your applications. Each family is optimized for specific use cases and workload patterns. This section includes memory techniques to help you remember each family.
Instance types follow the format: [Family][Generation][Additional Capabilities].[Size]
Example: m5a.large = M family, 5th generation, AMD processors, large size
Balanced compute, memory, and networking for diverse workloads. These are a good place to start, particularly if you're not sure what type to use.
Baseline CPU with ability to burst when needed
The t3 family is a burstable instance type. If you have an application that needs to run with some basic CPU and memory usage, you can choose t3. It also works well if you have an application that gets used sometimes but not others. When the resource is idle, you'll generate CPU credit, which you'll utilize when the resource is used.
Make sure you understand the difference between t3 and the older t2 โ t3 are in "unlimited mode" by default, so instead of throttling down to baseline CPU when your instance runs out of credits, you pay for overages.
Well-balanced compute, memory, and network resources
The m5 instance type is similar to t3, but for more consistent workloads. It has a nice balance of CPU, memory, and disk. It's not hard to see why almost half of EC2 workloads are on "m" instances. If you aren't sure what to choose, m5 is the most versatile of all the Amazon instance types.
Available variants: m6g (AWS Graviton2), m5a (AMD), m5n (enhanced networking), m4 (previous generation)
ARM-based processors for cost-effective scale-out workloads
The a1 instance type was announced in late 2018 and can be a less expensive option than other EC2. They are suited for scale-out workloads such as web servers, containerized microservices, caching fleets, distributed data stores, and development environments.
High-performance processors for CPU-intensive applications.
High ratio of compute/CPU versus memory
The c5 instance type has a high ratio of compute/CPU versus memory. If you have a compute-intensive application โ maybe scientific modelling, intensive machine learning, or multiplayer gaming โ these instances are a good choice.
Available variants: C5d (local NVMe SSD), C5n (enhanced networking up to 100 Gbps), C4 (previous generation)
Designed for workloads that process large data sets in memory.
High memory-to-vCPU ratio for memory-intensive applications
The r instance family is memory-optimized, which you might use for in-memory databases, real-time processing of unstructured big data, or Hadoop/Spark clusters. You can think of it as a kind of midpoint between the m5 and the x1e.
Available variants: R5a (lower cost per GiB), R5n (higher bandwidth)
Highest memory-to-vCPU ratio, up to 4TB RAM
The x1 family has a much higher ratio of memory, so this is a good choice if you have a full in-memory application or a big data processing engine like Apache Spark or Presto. X1e are optimized for high-performance databases, in-memory databases, and other memory intensive enterprise applications.
Up to 24TB of memory for largest workloads
We're not sure why these didn't get an alphabet soup name like the rest of the AWS instances, but at least it's easy to remember and understand. As you might guess, high memory instances run large in-memory databases, including production deployments of SAP HANA.
High compute performance with high memory and local NVMe storage
The z1d instances combine high compute capacity with a high memory footprint. They have a sustained core frequency of up to 4.0 GHz, the fastest of AWS's offerings. These are best for electronic design automation (EDA) and some relational database workloads with high per-core licensing costs.
Hardware accelerators or co-processors for specialized workloads.
NVIDIA Tesla GPUs optimized for machine learning training
If you need GPUs on your instances, p3 instances are a good choice. They are useful for video editing, and AWS also lists use cases of "computational fluid dynamics, computational finance, seismic analysis, speech recognition, autonomous vehicles" โ so it's fairly specialized.
GPUs optimized for graphics workstations and streaming
The g instance type uses Graphics Processing Units (GPUs) to accelerate graphics-intensive workloads, and also designed to accelerate machine learning inference. This could include adding metadata to an image, automated speech recognition, and language translation, as well as graphics workstations, video transcoding, and game streaming in the cloud.
Customizable hardware acceleration with FPGAs
f1 instances offer customizable hardware acceleration with field programmable gate arrays (FPGAs) โ hence the "f". Applications could include genomics research, financial analysis, and real-time video processing.
AWS Inferentia chips optimized for ML inference
The Inf1 instances are a specialized EC2 type for machine learning inference applications, such as recommendation engines, forecasting, image and video analysis, advanced text analytics, document analysis, voice, conversational agents, translation, transcription, and fraud detection.
Designed for workloads requiring high sequential read/write access to large datasets on local storage.
NVMe SSD-backed instance storage for high IOPS
The i3 instance type is similar to h1, but it is SSD backed, so if you need an NVMe drive, choose this type. Use it for NoSQL databases, in-memory databases, Elasticsearch, and more. The i3en option has higher network bandwidth with Elastic Network Adapter (ENA)-based enhanced networking.
High disk throughput with HDD-backed storage
d2 instances have an even higher ratio of disk to CPU and memory, which makes them a good fit for Massively Parallel Processing (MPP), MapReduce and Hadoop distributed computing, and similar applications.
Balance of compute and memory with HDD storage
The h1 type is HDD backed, with a balance of compute and memory. You might use it for distributed file systems, network file systems, or data processing applications.
As AWS has continued to add options to EC2, there are now EC2 instance types for almost any application. If you have comparison questions around pricing, run them through the AWS pricing calculator. And if you don't know, then generally starting with t3 or m5 is the way to go.
Understanding how EC2 pricing has evolved helps you optimize costs and take advantage of the latest billing improvements. This timeline shows the major changes in EC2 pricing models.
Pricing is per instance-hour consumed for each instance, from the time an instance is launched until it is terminated or stopped. Each partial instance-hour consumed will be billed per-second for Linux, Windows, Windows with SQL Enterprise, Windows with SQL Standard, and Windows with SQL Web Instances, and as a full hour for all other instance types.
Improvement: Extended per-second billing to Windows and SQL Server instances
Pricing is per instance-hour consumed for each instance, from the time an instance is launched until it is terminated or stopped. Each partial instance-hour consumed will be billed per-second for Linux Instances and as a full hour for all other instance types.
Major Change: Introduction of per-second billing for Linux instances (originally announced in 2017)
Pricing is per instance-hour consumed for each instance, from the time an instance is launched until it is terminated or stopped. Each partial instance-hour consumed will be billed as a full hour.
Original Model: Hourly billing only - even 1 minute of usage charged as full hour
The evolution to per-second billing provides significant cost savings for:
Now let's put theory into practice. We'll launch an EC2 instance, configure it with a web server using User Data, create a custom AMI, and deploy a new instance from that AMI.
The AWS Free Tier provides eligible users with 750 hours of t2.micro or t3.micro instances per month for the first 12 months after account creation. Always check the current Free Tier terms on the AWS website, as offerings may change over time. For accounts that have exceeded the Free Tier period, standard on-demand pricing applies.
Deploy an EC2 instance with automated web server installation using User Data scripts.
In the AWS Management Console, search for "EC2" and click on the EC2 service.
Click the "Launch instances" button to start the instance creation wizard.
Set the instance name to web-server-demo for easy identification.
Select Amazon Linux 2023 from Quick Start AMIs (current generation) or Amazon Linux 2 (extended support available).
Select t2.micro (eligible for Free Tier during first 12 months) or t3.micro (newer generation, also Free Tier eligible).
Choose an existing key pair or create a new one for SSH access. Download and securely store the private key.
web-server-sgConfigure the following inbound rules:
In Advanced Details, add this User Data script:
Review all settings and click "Launch instance" to create your EC2 instance.
Once your instance reaches "Running" state with "2/2 checks passed":
http://<public-ip>Important: Use http:// not https:// as we only configured HTTP (port 80).
Create a custom AMI from your configured instance for rapid future deployments.
In the EC2 console, select your web-server-demo instance.
Click Actions โ Image and templates โ Create image
custom-web-server-amiNavigate to AMIs in the left sidebar under Images. Wait for status to change from "pending" to "available" (typically takes 2-5 minutes).
Launch a new instance using your custom AMI to demonstrate rapid deployment.
In AMIs section, select custom-web-server-ami โ Actions โ Launch instance from AMI
web-from-custom-amiweb-server-sgLaunch the instance and verify it's immediately accessible via HTTP without waiting for User Data execution - this demonstrates the power of custom AMIs for rapid deployment.
You've successfully:
Important: Clean up resources to avoid unnecessary costs.
Select both instances โ Instance state โ Terminate instance
In AMIs section: Select custom AMI โ Actions โ Deregister AMI (also deletes associated snapshots)
In Security Groups: Select web-server-sg โ Actions โ Delete security group (only after instances are terminated)
Understanding EC2 pricing models is crucial for cost optimization. AWS offers several pricing options to match different usage patterns and business requirements.
Pay-as-you-go with no commitments
Up to 75% savings with 1 or 3-year commitment
Up to 90% savings using spare AWS capacity
Compliance & Licensing - Physical server isolation
Choose the optimal instance type and size for your workload to avoid over-provisioning or under-provisioning.
Monitor your application for at least 2 weeks to establish performance patterns and identify peak usage periods.
Use CloudWatch metrics to identify over-provisioned or under-provisioned resources. Look for consistent low utilization (under 20%) or high utilization (over 90%).
Before making changes to production, test new instance sizes in staging environments to validate performance and functionality.
Combine different pricing models to optimize costs while maintaining performance and availability.
Web Application:
Smart Scaling:
Risk vs. Reward:
Key Metrics to Track:
Don't overlook these often-missed cost factors:
Explore advanced EC2 capabilities that enable sophisticated architectures and optimize performance.
Attach a single EBS volume to multiple EC2 instances simultaneously for shared storage scenarios.
More info: EBS Multi-Attach Documentation
Customize CPU options for specific workloads requiring particular core/thread configurations.
More info: CPU Optimization Documentation
Mount S3 buckets as file systems for high-throughput access to S3 objects. This feature became generally available in 2023.
Benefits: Up to 100 GB/s throughput, optimized for read-heavy workloads, seamless S3 integration
Learn more: Mountpoint Announcement | AWS Blog
| EBS Volume Type | Max IOPS | Max Throughput | Best For |
|---|---|---|---|
| gp3 | 16,000 | 1,000 MB/s | General purpose, cost-effective |
| io2 | 64,000 | 1,000 MB/s | Critical applications, databases |
| io2 Block Express | 256,000 | 4,000 MB/s | Largest, most I/O intensive workloads |
| Instance Store | 3.3M+ | 14,000+ MB/s | Temporary, high-performance storage |
This educational content is designed for learning purposes and provides hands-on experience with AWS services. The guide combines theoretical knowledge with practical exercises to enhance understanding.
© 2025 Advizors - All rights reserved.
Product names and trademarks mentioned are property of their respective owners:
Use of these trademarks does not imply endorsement or affiliation.