EC2 (Elastic Compute Cloud)
💡 Definition
Amazon EC2 is a web service that provides secure, resizable compute capacity in the cloud. It allows you to launch virtual servers (instances) to run applications.
🔑 Key Concepts
- Instance Types: Different hardware configurations optimized for different tasks (e.g., Compute Optimized, Memory Optimized).
- AMI (Amazon Machine Image): The template used to create the instance (contains OS + apps).
- EBS (Elastic Block Store): The persistent network storage drive attached to the instance.
- Security Group: The virtual firewall that controls traffic to/from the instance.
- User Data: Script run once upon instance launch (for bootstrapping).
⚙️ How it Works
- Select Region: Choose where to run the server.
- Select AMI: Choose the OS (Linux, Windows).
- Choose Instance Type: Select CPU/RAM capacity (e.g.,
t2.micro). - Configure Network: Place in a VPC and Subnet.
- Attach Storage: Add EBS volumes.
- Launch: Connect via SSH (Linux) or RDP (Windows).
🎯 Use Cases
- Hosting websites and web applications.
- Running backend servers and APIs.
- High-performance computing (HPC) and batch processing.
- Gaming servers.
💰 Pricing Model
- On-Demand: Pay by the second/hour (no commitment).
- Reserved Instances: 1-3 year commitment for discount (up to 72%).
- Savings Plans: Commit to usage ($/hr) for discount.
- Spot Instances: Bid on spare capacity (up to 90% off, can be interrupted).
📝 Exam Tips (CLF-C02)
- Remember that EC2 is IaaS (Infrastructure as a Service).
- You are responsible for OS patching (Shared Responsibility Model).
- Vertical Scaling: Changing instance type (e.g.,
t2.microtot2.large). - Horizontal Scaling: Adding more instances (using Auto Scaling Group).
See Also: * Auto Scaling * Load Balancer