Amazon EC2 (Elastic Compute Cloud)
Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.
Key Features
- Instances: Virtual servers. High flexibility in configuration (CPU, Memory, Storage, Networking).
- Amazon Machine Images (AMIs): Pre-configured templates for your instances (includes OS and software).
- Instance Types:
- General Purpose (T, M): Balanced resources. T-series are burstable.
- Compute Optimized (C): High performance processors (batch processing, gaming, HPC).
- Memory Optimized (R, X, High Memory): Fast performance for workloads that process large data sets in memory (RAM).
- Accelerated Computing (P, G, F): Hardware accelerators/GPUs (ML, Graphics).
- Storage Optimized (I, D, H): High, sequential read and write access to very large data sets.
- User Data: Scripts entered during launch to effect the running instance (e.g., install software). Runs only once on first boot.
- Storage:
- Instance Store: Ephemeral storage (data lost on stop/terminate). Physically attached to host.
- Amazon EBS: Persistent block storage. Network attached.
- Networking:
- Security Groups: Stateful firewall at the instance level.
- Key Pairs: Secure login information (PEM/PPK files).
- Placement Groups:
- Cluster: Low latency, high bandwidth (same rack/AZ).
- Spread: Distributed across distinct hardware (critical instances).
- Partition: Distributed across logical partitions (Hadoop/Cassandra).
Pricing Models
- On-Demand: Pay by the second/hour. No commitment. High cost. Good for short-term, irregular workloads.
- Reserved Instances (RI): 1 or 3 year commitment. Up to 72% discount.
- Standard RI: Less flexible, higher discount.
- Convertible RI: More flexible (can change instance type), lower discount.
- Savings Plans: Commitment to a consistent amount of usage ($/hr) for 1 or 3 years. Flexible across families/regions (Compute Savings Plans).
- Spot Instances: Unused capacity. Up to 90% discount. Can be interrupted with 2 mins notice. Good for fault-tolerant, stateless workloads.
- Dedicated Hosts/Instances: Physical servers dedicated for your use (compliance/licensing).
Exam Tips
- Spot Instances: Always think "Cheap" and "Stateless/Interrupriable". If the exam mentions "cost-optimized" and "interruption is okay", choose Spot.
- Reserved/Savings Plans: If the exam mentions "predictable usage" or "long-term commitment" for >1 year, choose RI or Savings Plans.
- Security Groups vs NACLs:
- Security Groups are Stateful (return traffic allowed automatically).
- NACLs are Stateless (return traffic must be explicitly allowed) and work at subnet level.
- User Data: Used for "Bootstrapping".
- Instance Store vs EBS:
- Instance Store = High performance, but Ephemeral (Lose data on stop).
- EBS = Persistent, Network drive.
Common Use Cases
- Hosting Web Applications.
- High Performance Computing (HPC).
- Batch Processing.
- Gaming Servers.
- Applications requiring full OS control.