EC2 is the backbone of AWS and encompasses a bundle of services, mainly
By default, an instance comes with
EC2 instances can run scripts on startup based on User Data
.
As per SLA, EC2 guarantees a monthly uptime of at least 99.99% with EBS in a region.
Offers variety of CPU options including AMD (x86), Intel (x86), ARM etc.
Loosely based on Linux KVM.
You can query the metadata (instance ID, network interface) by
$ curl[<http://169.254.169.254/latest/meta-data/>](<http://169.254.169.254/latest/meta-data/>)
On demand: short workload, predictable pricing
Reserved (min 1 year)
Reserved Instance: long workloads
Convertible Reserved Instance
Scheduled Reserved Instance — every Thursday, 3p-6p
Up to 75% cheaper, pay upfront for 1-3 year period
Suitable for traditional IT uses
To take advantage of capacity reservation, you should buy RI in a specific AZ (zonal RI)
You can purchase RI for an already running instance
You can sell your RIs to other customers on AWS Marketplace if no longer needed
Analogy: Planning and booking way ahead of time to get a discount.
Spot: short workloads, cheap but unreliable
max_spot_price
and get the instance while current_spot_price
< max_spot_price
Spot fleets = set of spot instances + (optional) on-demand instances
EC2 fleet = same as Spot fleet, don't migrate
Dedicated instances: No other customer will share your hardware
Dedicated hosts: book an entire physical server
Best combo: Reserved for baseline + On-demand/Spot for spikes