AWS EC2 Networking Basics
Important to remember!
When you stop and then start an EC2 instance, it can change its public IP!
So if you need a fixed public IP for an instance, you must use an Elastic IP – or else register your own public IP and domain name
You own the Elastic IP as long as you don’t delete it, you can attach it to one instance.
but you can remap the ip address to another instance in your account in the event of an instance or software failure.
But – you can only have max 5 Elastic IPs in your account.
Best practice: DON’T use Elastic IP but instead use your own registered public ip with a registered domain name. You can do this via AWS Route 53.
Even better, you can use a load balancer to connect to the private ip addresses of your instances.
Always remember – your EC2-allocated public ip will change if you shutdown and restart the instance!
The *private* iP however always remains the same.
You allocate an Elastic IP to an EC2 instance from your EC2 Dashboard.
EC2 Placement Groups (PGs)
these give you control over where your EC2 instances are placed.
This gives you a way to specify where you want your EC2s to be physically located.
Placement groups can be cluster, spread or partition-based
all in same hw rack
in same AZ
pro: network speeds high between instances
con: high risk of total failure if the rack fails – because all EC2 instances will fail together
use cases: best for big data that must be quickly processed
this minimizes risk compared to cluster PG
instances across different AZs
and across different hw racks
pro: less risk of failure
con: you are allowed max 7 instances per AZ per PG permitted
use cases: best for high availability, critical applications that must be isolated from failure from each other
each partition = one rack
you can have multiple partitions – 7 maximum in each AZ in same region
100s of EC2s per partition possible
– failure can affect other EC2s on same rack, but not other partitions
can use metadata service to get info about other EC2s on the partition
use cases include apache-kafka, hdfs, cassandra
ENI Elastic Network Interfaces
This is the AWS virtual network interface
it can have
one private primary IPv4 address
one or more secondary IPv4 addresses
one Elastic IP per private IPv4
one public IPv4
one or more security groups
a MAC address
you can move ENIs to other instances of EC2 on failover!
but note – ENIs are bound to a specific AZ