AWS Elastic Cloud Compute (EC2) incubating
Scope
az scope - specify 1 az
Multi region replication?
AMI = replicate via lambda, or life cycle rules or AWS Backup
AutoScaling
AutoScaling groups - can use launch templates or launch configs.
Launch templates allow using latest EC2 features including selecting instances based on defined attributes rather than adding a fixed instance type.
Lifecycle hooks
Lifecycle hooks provide a way to trigger custom workflows based on the scale-in or scale-out activity in an auto scaling group. By default, the hooks provide a 1 hr window before transitioning to the next stage. Alternatively, the custom workflow can post either ABANDON
or CONTINUE
using complete-lifecycle-action
cli command.
aws autoscaling complete-lifecycle-action --lifecycle-action-result CONTINUE --lifecycle-hook-name my-launch-hook --auto-scaling-group-name my-asg --lifecycle-action-token alpha-numeric-token
When the instance is being terminated, both ABANDON
ang CONTINUE
result in termination. ABANDON
only prevents any more subsequent lifecycle hooks to run.
When the instance is being created, ABANDON
prevents the instance from being launched, while CONTINUE
allows the instance to be launched.
By default, the lifecycle hooks publish events to eventbridge, from where, rules can be created to send these events to any supported destination like SQS, SNS, Lambda etc.
Usecase
- capture an instance termination event, copy files or logs from the instance before they get lost!
- use the lifecycle hook command in the instance userdata script to signal to auto-scaling group all initialization steps are complete, and the instance can be marked in service ready to accept traffic.
Termination Protection
Enable EC2 termination protection - not applicable to services like Autoscaling
Suspend Autoscaling ReplaceUnhealthy scaling process
Instance scale-in protection on Autoscaling group
Systems Manager
Placement Groups
- Cluster – Packs instances close together inside an Availability Zone. This strategy enables workloads to achieve the low-latency network performance necessary for tightly-coupled node-to-node communication that is typical of high-performance computing (HPC) applications.
- Partition – Spreads your instances across logical partitions such that groups of instances in one partition do not share the underlying hardware with groups of instances in different partitions. This strategy is typically used by large distributed and replicated workloads, such as Hadoop, Cassandra, and Kafka.
- Spread – Strictly places a small group of instances across distinct underlying hardware to reduce correlated failures.
Purchasing Options
On-Demand
Reserved Instances
Standard RI
provides you with a significant discount on EC2 usage (a particular instance family) when you commit to a one-year or three-year term.
Convertible RI
Region specific, allows for customization to instance properties down the road, or even exchange for a new convertible RI
Zonal RI
When a Standard or Convertible RI is scoped to a specific Availability Zone (AZ), instance capacity matching the exact RI configuration is reserved for your use (these are referred to as “zonal RIs”). Zonal RIs give you additional confidence in your ability to launch instances when you need them.
Regional RI
Regional RIs provide AZ and instance size flexibility but no capacity reservation
Spot
Dedicated Hosts
Dedicated Instances
Capacity Reservations
Capacity Blocks for ML
Reserve GPU capacity for ML workloads on UltraClusters.
reserve upto 14 days in 1 day increments
instances - 1, 2, 4, 8, 16, 32 and 64
instance type | region |
---|---|
p5.48xlarge | us-east-1 , us-east-2 |
p4d.24xlarg | us-east-2 , us-west-2 |
On-demand capacity reservation
Reserve capacity for Prime day like events to ensure you get all the capacity you need on your big day.
Fleet
Launch mix of instances cross-az with on-demand, spot, reserved ri billing models.
Savings Plans
Compute Savings Plans = EC2, Fargate, Lambda
EC2 Instance Savings Plans = EC2 family in a region
Questions
What are Burstable Instances
uses and differences between reserved instances, compute savings plans, capacity reservations? Is there anything called instance savings plan?