EC2 is AWS's most widely used service. When you want to run your own server in the cloud, you start with EC2. But there are so many options that the wrong choice can multiply your month-end bill.
01. Instance Types
There are hundreds of instance types on EC2. The main families:
- t3, t4: general purpose, economical
- m5, m6: balanced, typical web server
- c5, c6: CPU-heavy workloads
- r5, r6: RAM-heavy (database, cache)
- p3, p4: GPU (ML, AI)
02. Pricing Models
Three main payment paths:
- On-Demand: hourly, no commitment, most expensive
- Reserved: 1- or 3-year commitment, 30-75% discount
- Spot: up to 90% discount, but AWS can reclaim it at any moment
03. AMI Selection
For the operating system you can use Amazon Linux (AWS-optimized), Ubuntu (the Linux world standard), Windows Server or RHEL. Amazon Linux integrates best with AWS.
04. Security Groups
A security group is like a firewall. Which port (SSH:22, HTTPS:443) is granted access from which IP — that's defined here. Misconfigured, the server stays open to the whole world.
05. Auto Scaling
The number of servers automatically increases and decreases with traffic. Ideal for an e-commerce site's Black Friday scenario. But it's complex; manual management is safer at first.