Learn: Compute in the Cloud
Concept-focused guide for Compute in the Cloud (no answers revealed).
~7 min read

Overview
Welcome, cloud learners! In this guide, we’ll demystify key Amazon EC2 and related AWS compute concepts, preparing you for both real-world cloud deployments and exam success. You’ll gain a clear understanding of how EC2 instance types, billing models, auto scaling, load balancing, and AWS messaging services fit together to deliver scalable, resilient, and cost-effective cloud solutions. Expect practical explanations, strategic tips, and worked examples to solidify your mastery of these foundational AWS topics.
Concept-by-Concept Deep Dive
1. Amazon EC2 Instance Types and Features
What it is:
Amazon EC2 offers a range of virtual server types (instances), each optimized for particular workloads—compute, memory, storage, or networking. Understanding the differences ensures you select the best match for your application’s requirements and budget.
Instance Categories:
- General Purpose: Balanced compute, memory, and networking. Good for web servers, development environments.
- Compute Optimized: High-performance CPUs for compute-heavy tasks (e.g., scientific modeling, batch processing).
- Memory Optimized: Large memory footprints for in-memory databases or analytics.
- Storage Optimized: High, fast local storage for applications like NoSQL databases.
- Accelerated Computing: GPUs or FPGAs for machine learning or graphics-intensive workloads.
Special Features:
- Instance Store Volumes: Temporary storage physically attached to the host. Data is lost if the instance stops/terminates.
- Dedicated Hosts/Instances: Hardware resources dedicated to a single customer for regulatory, compliance, or licensing needs.
- High-Networking Instances: Designed for high throughput and low latency, important for HPC or real-time analytics.
Reasoning Recipe:
- Match workload characteristics (CPU, RAM, storage, network) to instance family.
- For compliance or licensing, consider dedicated options.
- For temporary, high-speed storage, look at instance store volumes.
Common Misconceptions:
- Assuming all storage is persistent—instance store is not.
- Believing all instances are equally suited for every workload.
2. EC2 Billing and Pricing Models
What it is:
AWS offers several payment models for EC2, each catering to different usage patterns and cost optimization strategies.
Major Billing Options:
- On-Demand: Pay by the second/minute, no commitment. Flexible but pricier.
- Reserved Instances (RIs): Commit to a time period (1 or 3 years) for lower rates. Options for capacity reservation and flexibility in instance attributes.
- Spot Instances: Bid for unused capacity at steep discounts. Can be interrupted by AWS.
- Savings Plans: Flexible, commitment-based pricing across instance families, OS, and regions.
Step-by-Step Cost Optimization:
- Use On-Demand for unpredictable workloads, testing, or short-term needs.
- Use Reserved or Savings Plans for steady-state or predictable workloads.
- Use Spot Instances for fault-tolerant, flexible-timing workloads.
- Mix and match for best overall savings.
Common Misconceptions:
- Confusing reserved capacity with reserved pricing.
- Not understanding that Spot Instances can be interrupted at short notice.
3. EC2 Auto Scaling
What it is:
EC2 Auto Scaling automatically adjusts the number of running instances in response to demand, maintaining availability and optimizing cost.
Key Functions:
- Scale-Out: Adds instances during high traffic to maintain performance.
- Scale-In: Removes instances during low traffic to save costs.
- Health Checks: Automatically replaces unhealthy instances.
Scaling Policies:
- Dynamic Scaling: Responds to metrics (CPU, network) for scaling decisions.
- Scheduled Scaling: Predefined changes based on expected traffic patterns.
Reasoning Recipe:
- Set up scaling policies based on workload patterns.
- Use health checks to ensure only healthy instances serve traffic.
Common Misconceptions:
- Believing scaling is instantaneous—there is always a spin-up time.
- Ignoring the importance of scaling in (cost savings during off-peak).
4. Elastic Load Balancing (ELB)
What it is:
Elastic Load Balancing automatically distributes incoming traffic across multiple targets (instances, containers, IPs), improving both reliability and performance.
Types and Features:
- Application Load Balancer (ALB): Layer 7 (HTTP/HTTPS), advanced routing, host/path-based.
- Network Load Balancer (NLB): Layer 4 (TCP/UDP), ultra-low latency, suited for high-throughput.
- Classic Load Balancer (legacy): Basic Layer 4/7.
Key Capabilities:
- Health Checks: Routinely test each target’s health; only healthy targets receive traffic.
- Multi-AZ Distribution: Spreads load across multiple Availability Zones for high availability.
- Protocol Support: Handles protocols like HTTP, HTTPS, TCP, etc.
- Monitoring: Metrics on traffic, latency, health, and errors.
Reasoning Recipe:
- Choose the right load balancer type for your application’s protocol needs.
- Enable health checks to avoid serving traffic to unhealthy instances.
- Distribute traffic across AZs for resilience.
Common Misconceptions:
- All load balancers are equal; in reality, each is optimized for specific use cases.
- Health checks are optional—for high availability, they are essential.
5. AWS Messaging Services: SNS vs SQS
What it is:
Amazon SNS and SQS both enable message-based architectures but serve different purposes.
SNS (Simple Notification Service):
- Pub/Sub model: Publishers send messages to topics; subscribers receive messages pushed directly to them (email, SMS, Lambda, HTTP endpoints).
- Use Case: Real-time notifications, fan-out message distribution.
SQS (Simple Queue Service):
- Message Queue: Producers send messages to a queue; consumers poll and process messages at their pace.
- Use Case: Decoupling distributed systems, buffering requests, ensuring reliable delivery.
Step-by-Step Reasoning:
- Use SNS when you want immediate, multi-protocol push notifications.
- Use SQS to buffer, decouple, and reliably deliver messages between loosely coupled components.
Common Misconceptions:
- Assuming SQS delivers messages instantly like SNS.
- Expecting SNS to guarantee message persistence if subscribers are offline.
Worked Examples (generic)
Example 1: Choosing an EC2 Instance Type
You have a data analytics workload that requires large amounts of RAM and fast storage, but only moderate CPU.
Solution Process:
- Identify memory-optimized instance types.
- Evaluate if instance store volumes are needed for temporary, high-speed storage.
- Consider persistence requirements—if data must survive instance stops, use EBS instead.
Example 2: Selecting a Billing Model
Suppose your web application runs 24/7 with predictable demand.
Solution Process:
- Compare On-Demand vs Reserved pricing.
- Calculate cost savings over 1 or 3 years with RIs or Savings Plans.
- Decide on standard (fixed) vs convertible (flexible attributes) RIs.
Example 3: Applying Auto Scaling
Your video streaming site experiences spikes during live events.
Solution Process:
- Set up dynamic scaling policies based on CPU/network usage.
- Ensure minimum and maximum instance counts are set appropriately.
- Use scheduled scaling if spikes are predictable (e.g., always at 8pm).
Example 4: Deciding Between SNS and SQS
An app needs to notify users instantly upon sign-up, and also process background jobs like image resizing.
Solution Process:
- Use SNS to push notifications to users (SMS/email/HTTP).
- Use SQS to queue image jobs so workers can process at their own rate.
Common Pitfalls and Fixes
-
Ignoring Instance Store Volatility:
Pitfall: Storing critical data on instance store volumes.
Fix: Use EBS for persistent storage, and only use instance store for temporary data. -
Confusing Billing Options:
Pitfall: Committing to Reserved Instances without understanding lack of flexibility.
Fix: Review workload predictability and consider Convertible RIs or Savings Plans for flexibility. -
Not Configuring Health Checks:
Pitfall: Load Balancer sending traffic to failed targets.
Fix: Always enable and properly configure health checks. -
Overprovisioning During Off-Peak:
Pitfall: Auto Scaling group not scaling in, wasting money at night.
Fix: Set minimum instance counts appropriately and enable scale-in policies. -
Misusing SNS and SQS:
Pitfall: Expecting SNS to store messages for offline subscribers or SQS to push messages in real-time.
Fix: Match use case to service: SNS for push, SQS for reliable, decoupled queues.
Summary
- EC2 instance types are tailored to specific resource profiles: compute, memory, storage, and networking.
- AWS offers four main EC2 billing models—choose based on workload predictability and flexibility needs.
- Auto Scaling ensures your application matches demand, boosting performance and controlling costs.
- Elastic Load Balancing distributes traffic, monitors target health, and supports high availability across multiple AZs.
- SNS and SQS address different messaging needs: SNS for fan-out push notifications, SQS for decoupled, reliable queues.
- Always configure health checks, right-size your scaling, and select instance and pricing options that best fit both technical and business requirements.
Join us to receive notifications about our new vlogs/quizzes by subscribing here!