Amazon EC2
Amazon Elastic Compute Cloud (EC2) provides resizable compute capacity in the cloud. It's the foundational compute service of AWS, offering virtual servers (instances) that you can configure and manage.
Key Concepts
- Instances: Virtual servers with configurable CPU, memory, storage, and networking
- AMIs: Amazon Machine Images - templates for launching instances
- Instance Types: Different combinations of resources (e.g., t3.micro, m5.large, c6g.xlarge)
- Security Groups: Virtual firewalls controlling inbound/outbound traffic
- Key Pairs: SSH credentials for secure access
Instance Categories
| Family | Optimised For | Example Use Cases |
|---|---|---|
| T | Burstable | Web servers, dev environments |
| M | General purpose | Application servers, backends |
| C | Compute | Scientific modeling, batch processing |
| R | Memory | In-memory caching, databases |
| G/P | GPU | Machine learning, graphics rendering |
Purchasing Options
| Option | Best For | Savings |
|---|---|---|
| On-Demand | Unpredictable workloads | - |
| Reserved | Steady-state usage | Up to 72% |
| Spot | Fault-tolerant, flexible workloads | Up to 90% |
| Savings Plans | Consistent compute usage | Up to 72% |
What We Like
- Flexibility: Complete control over the operating system and configuration
- Instance variety: Options for virtually any workload
- Spot instances: Massive savings for appropriate workloads
- Mature ecosystem: Extensive tooling and documentation
What We Don't Like
- Operational overhead: Patching, scaling, and monitoring are your responsibility
- Cost management: Easy to leave instances running and accumulate costs
- Complexity: Many options can be overwhelming
When to Use EC2
EC2 is appropriate when you need:
- Full control over the compute environment
- Specific OS or software requirements
- Persistent, stateful workloads
- GPU or specialised hardware access
For stateless, event-driven workloads, consider Lambda instead. For containerized applications, ECS or EKS may be more appropriate.