EC2 is AWS's virtual server service. Instances can be created, started, stopped, and terminated on demand.
How EC2 Works
When creating an EC2 instance, you usually choose:
- AMI: operating system and preinstalled software
- Instance type: CPU, memory, and networking capacity
- Storage configuration
- Network and security groups
You can connect through SSH, RDP, or AWS Systems Manager.
Instance Types
General purpose: balanced compute, memory, and networking. Good for web services.
Compute optimized: high CPU workloads.
Memory optimized: large datasets, caches, and databases.
Accelerated computing: GPU or hardware acceleration.
Storage optimized: high I/O and local storage workloads.
Pricing Models
Common pricing options:
- On-Demand Instances
- Reserved Instances
- Savings Plans
- Spot Instances
Choose based on whether the workload is stable, interruptible, and long-running.
Auto Scaling and Load Balancing
Auto Scaling automatically adds or removes instances based on demand.
Elastic Load Balancing distributes traffic across multiple targets to improve availability.
Messaging Services
SQS is a queue service for decoupling producers and consumers.
SNS is a pub/sub service for pushing messages to multiple subscribers.
EventBridge supports event-driven architectures across AWS services and applications.