Instances
Instances
- Amazon Machine Image
- Instance type:
- m5.2xlarge:
- m: instance class
- 5: generation of instance class
- 2xlarge: size
- ec2instance.info
- Key pair
- Network
- Advanced details:
- .
- Stop - hibernation behavior:
- stop but store the RAM state in a file in root EBS
- root EBS volume must be encrypted
- startup much faster
- not more than 60 days
- .
- Spot instance: set max price
- …
- User data: script to be run when instance first created.
Instance types
Launch template
- AMI
- Instance type
- EC2 User data
- EBS volumes
- SGs
- SSH key pair
- IAM roles
- Network + subnet
- Load balancer
Spot requests
- Spot instance: set max price willing to pay, if price goes above, instance is stopped
- Spot fleet: set of spot instances + (optional) on-demand instances
- automatically request spot instances to adjust to reach capacity or max defined cost
- can have multiple launch pool for fleet to choose from
- strats:
- lowest price
- diversified
- capacity optimized
- price-capacity optimized
Saving plans
Reserved Instances
- up to 72% discount compared to on-demand
- 1 year / 3 years: 3 years has more discount
- All upfront payment has more discount > partial > no upfront
- Convertible RI: can change EC2 instance type, family, os, scope
Dedicated hosts
- Dedicated Instances offer single-tenant virtual machines on shared hardware
- Dedicated Hosts provide entire physical servers for exclusive use.
Capacity reservation
- Reserve capacity in a specific AZ so work is uninterupted
Volumes
- exist in single az
- volume types:
- gp2: general purpose SSD, IOPS depends on size
- gp3: general purpose SSD, IOPS scales independently
- io1: provisioned SSD, high max IOPS
- allows for multi-attach in same az, up to 16
- io2: provisioned SSD, higher max IOPS
- allows for multi-attach in same az, up to 16
- st1: HDD, slow
- sc1: HDD, slowest
-
- HDD can be used for log processing and big data
- Volumes attached to root is deleted when instance is terminated by default
Snapshots
Network & security
Placement groups:
- Control over instance placements in a ASG
- Strategies:
- Cluster: in single AZ
- higher network speed between instances (turn on enhanced networking)
- Spread: across multiple AZ (max 7 in each group per AZ)
- Partition: across different partitions (different set of racks) for each AZs. Up to 100s of instance per group
Key pairs
Network interfaces:
- Virtual Network Interface Card
- Independent from instance, can be detached and moved
- Exist in a single AZ
- Has:
- at least 1 private IPv4
- 1 elastic IPv4 per private IPv4
- max 1 elastic public IPv4
- 1 or more SG
- MAC address
Load Balancing
AS
Auto Scaling Group
- Amazon AutoScaling
- Scale based on Alarms (avg cpu usage)
-
Details:
- Activity:
- Automatic scaling policies:
- Dynamic scaling policies
- target tracking scaling: set to have avg cpu to x%
- simple/step scaling: trigger when avg CPU > x% → add 1
- scheduled scaling:
- set to add 1 instance at x-AM
- Predictive scaling: forecast load and schedule scaling ahead
- Instance management: