EC2 Solution Architect Associate
Elastic IPβ
- Static Public IP that you own as long as you don't delete it
- Can be attached to an EC2 instance (even when it is stopped)
- Soft limit of 5 elastic IPs per account
- Doesnβt incur charges as long as the following conditions are met (EIP behaving like any other public IP randomly assigned to an EC2 instance):
- The Elastic IP is associated with an Amazon EC2 instance
- The instance associated with the Elastic IP is running
- The instance has only one Elastic IP attached to it
Placement Groups (Placement Strategies)β
-
Cluster Placement Group (optimize for network)
- All the instances are placed on the same hardware (same rack in same AZ)
- Pros: Great network (10 Gbps bandwidth between instances) low latency, high profermance
- Cons: If the rack fails (AZ), all instances will fail at the same time
- Used in HPC (minimize inter-node latency & maximize throughput) and Big data job that needs to complete fast
-
Spread Placement Group (maximize availability)
- Each instance is in a separate rack (physical hardware) inside an AZ
- Supports Multi AZ
- Up to 7 instances per AZ per placement group (ex. for 15 instances, need 3 AZ)
- Reduce the risk and Used for critical applications
-
Partition Placement Group (balance of performance and availability)
- Instances in a partition share rack with each other
- If the rack goes down, the entire partition goes down
- Up to 7 partitions per AZ
- Used in big data applications (Hadoop, HDFS, HBase, Cassandra, Kafka)
If you receive a capacity error when launching an instance in a placement group that already has running instances, stop and start all of the instances in the placement group, and try the launch again. Restarting the instances may migrate them to hardware that has capacity for all the requested instances.
Elastic Network Interface (ENI)β
- ENI is a virtual network card that gives a private IP to an EC2 instance
- A primary ENI is created and attached to the instance upon creation and will be deleted automatically upon instance termination.
- We can create additional ENIs and attach them to an EC2 instance to access it via multiple private IPs.
- We can detach & attach ENIs across instances
- ENIs are tied to the subnet (and hence to the AZ)
Instance Statesβ
-
Stop
- EBS root volume is preserved
-
Terminate
- EBS root volume gets destroyed
-
Hibernate
-
Hibernation saves the contents from the instance memory (RAM) to the EBS root volume
-
EBS root volume is preserved
-
The instance boots much faster as the OS is not stopped and restarted
-
When you start your instance:
- EBS root volume is restored to its previous state
- RAM contents are reloaded
- Processes that were previously running on the instance are resumed
- Previously attached data volumes are reattached and the instance retains its instance ID
-
Should be used for applications that take a long time to start
-
Not supported for Spot Instances
-
Max hibernation duration = 60 days
-
Standby
- Instance remains attached to the ASG but is temporarily put out of service (the ASG doesn't replace this instance)
- Used to install updates or troubleshoot a running instance
Storageβ
Monitoringβ
- coming soon
Amazon Machine Image (AMI)β
- AMIs are the image of the instance after installing all the necessary OS, software and configuring everything.
- It boots much faster because the whole thing is pre-packaged and doesnβt have to be installed separately for each instance.
- Good for static configurations
- Bound to a region (can be copied across regions)
When the new AMI is copied from region A into region B, it automatically creates a snapshot in region B because AMIs are based on the underlying snapshots.
Examplesβ
Update system package repositoryβ
sudo yum update -y
Install Apache (httpd)β
sudo yum install -y httpd
Start Apache serviceβ
sudo systemctl start httpd
Enable Apache to start at bootβ
sudo systemctl enable httpd
Create a custom HTML fileβ
cat <<EOF > /var/www/html/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to My Website</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a custom HTML page served from my Apache server on EC2.</p>
</body>
</html>
EOF
Restart Apache to apply changesβ
sudo systemctl restart httpd