🖥️

EC2

Owner
Verification
Tags
Last edited time

Instance Types

R (memory) C (compute CPU DB) M (gpu) I (I/O databasses) G (GPU) T (burst)

EC2 Graviton - linux unix only - best price / performance HPC

Placement group

Can move in or out (need to stop > move >then start)

Launch Types

On Demand - short predictable workload

Spot - Short workload not reliable

Reserved - Long workload (1-3 years), convertible - flexible reservation

♦️
To exclude an OU from the RI - Turn off the Reserved Instance (RI) sharing on the master account for all of the member accounts in the Baby products business unit.

Dedicated host: own HW, control placement (licenses) - no other client

(using host affinity that keeps the EC2 on the same host)

AWS Savings Plan - commit to $ per H or Y - beyond will be charged as on demand

EC2 - up to 70% , Compute up to 66%(EC2, Fargate, Lambda) , Sage Maker 64%

Monitoring

CPU, Credit, Networking, System & Status checks, Disk, for RAM - need CW agent

can recover EC2 on system check with same IP and metadata and placement

EC2Rescue

Diagnose and troubleshoot problems on Amazon EC2 Linux and Windows Server instances. You can run the tool manually or automatically with SSM  AWSSupport-ExecuteEC2Rescue

EC2 Instance Connect

the service sends “SendSSHPublicKey API” - get 60 sec token

need to enable port 22 for AWS IP range 18.206.106.24/29

https://ip-ranges-amazonaws.com/ip-ranges.json

EC2 Spot Instances

Spot request - set max price for request , specify launch template

Spot fleet - collection of spot + on demand (option) , can mix EC2 type.

supports: ASG, ECS, Batch - up to 10k target capacity , 100k per region

will be launched by a launch pool (AZ,OS,Type) until it hit a target - can set strategies:

lowesPrice: from the pool with lowest price - short workload

diversified: across all pools - availability, long workloads

capacityOptimized: optimal capacity for number of EC2

Lightsail

cheap and easy way to deploy virtual machines (like ec2) with networking and storage and DB and ELB - deploy compute without experience

Shutdown Behavior

can set: stop = terminate

can set termination protection (only if you do it from AWS , if from the OS = terminated ! )

Launch Troubleshooting

#InstanceLimitExceeded = max number of vCPU per Region : Request increase (on demand/spot)

#InsufficientInstanceCapacity = AWS issue in the AZ = change type, number of ec2 . change AZ

#Instance Terminates Immediately = EBS volume limit / root encrypted / snapshot corrupt / KMS / AMI missing a part

SSH Troubleshooting

“Unprotected private key = no permissions to the key file

“Host not found” . permission denied = wrong user name

connection timed out = security group / NACL / IP

Purchasing Options

Reserved Instances: 72% , 1-3 years , per region/AZ = specific attributes ( Databases )

EC2 Savings Plans: commit to usage over time , specific EC family & region (can change size)

Dedicated Host : Physical server fully dedicated (compliance / license )

Dedicated Instance: no control over placement , no access to the HW

Capacity Reservation - can reserve on demand capacity in a specific AZ / Region

Elastic Ip

up to 5 per account

CloudWatch for EC2

Basic Monitoring (default) - 5 minutes

Detailed monitoring (paid) - 1 minute (CPU, disk, status)

Custom metic - 1 min - 1 sec (RAM) + needs IAM role on EC2 (RAM) - need agent + IAM role + SSM configuration file

can collect OS process using procstat Plugin

EC2 metrics:

CPU: utilization + credit , Network: in / out, instance (VM) , System (HW)

TIPS for EC2:

IPv6:

Support from M4 large and up, need to configure Egress only NAT gateway, Create a subnet with a /64 IPv6 CIDR block in your VPC.

EC2 Checks:

System check: host (net/power/SW issue / HW issue) – wait for AWS / move host

Status check: VM (net/mem/file system/kernel) – Reboot/ reconfigure

EC2 Hibernate

RAM (in memory state) is reserved – fast boot (Root EBS volume must be encrypted)

EC2 Attributes

a – AMD, g –Graviton i – Intel , d – Instance store

n – Network b – Block storage, e – Extra storage or memory , z – High frequency