EC2 – Associate

Private vs Public IP (IPv4)

β€’ Networking has two sorts of IPs. IPv4 and IPv6:

β€’ IPv4: 1.160.10.240

β€’ IPv6: 3ffe:1900:4545:3:200:f8ff:fe21:67cf

β€’ In this course, we will only be using IPv4.

β€’ IPv4 is still the most common format used online.

β€’ IPv6 is newer and solves problems for the Internet of Things (IoT).

β€’ IPv4 allows for 3.7 billion different addresses in the public space

β€’ IPv4: [0-255].[0-255].[0-255].[0-255].

Private vs Public IP (IPv4) Fundamental Differences

β€’ Public IP:

β€’ Public IP means the machine can be identified on the internet (WWW)

β€’ Must be unique across the whole web (not two machines can have the same public IP).

β€’ Can be geo-located easily

β€’ Private IP:

β€’ Private IP means the machine can only be identified on a private network only

β€’ The IP must be unique across the private network

β€’ BUT two different private networks (two companies) can have the same IPs.

β€’ Machines connect to WWW using a NAT + internet gateway (a proxy)

β€’ Only a specified range of IPs can be used as private IP

Elastic IPs

β€’ When you stop and then start an EC2 instance, it can change its public IP.

β€’ If you need to have a fixed public IP for your instance, you need an Elastic IP

β€’ An Elastic IP is a public IPv4 IP you own as long as you don’t delete it

β€’ You can attach it to one instance at a time

β€’ With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account.

β€’ You can only have 5 Elastic IP in your account (you can ask AWS to increase that).

β€’ Overall, try to avoid using Elastic IP:

β€’ They often reflect poor architectural decisions

β€’ Instead, use a random public IP and register a DNS name to it

β€’ Or, as we’ll see later, use a Load Balancer and don’t use a public IP

Private vs Public IP (IPv4) In AWS EC2 – Hands On

β€’ By default, your EC2 machine comes with:

β€’ A private IP for the internal AWS Network

β€’ A public IP, for the WWW.

β€’ When we are doing SSH into our EC2 machines:

β€’ We can’t use a private IP, because we are not in the same network

β€’ We can only use the public IP.

β€’ If your machine is stopped and then started, the public IP can change

Placement Groups

β€’ Sometimes you want control over the EC2 Instance placement strategy

β€’ That strategy can be defined using placement groups

β€’ When you create a placement group, you specify one of the following strategies for the group:

β€’ Clusterβ€”clusters instances into a low-latency group in a single Availability Zone

β€’ Spreadβ€”spreads instances across underlying hardware (max 7 instances per group per AZ)

β€’ Partitionβ€”spreads instances across many different partitions (which rely on different sets of racks) within an AZ. Scales to 100s of EC2 instances per group (Hadoop, Cassandra, Kafka)

Cluster

β€’ Pros: Great network (10 Gbps bandwidth between instances with Enhanced Networking enabled - recommended)

β€’ Cons: If the rack fails, all instances fails at the same time

β€’ Use case:

β€’ Big Data job that needs to complete fast

β€’ Application that needs extremely low latency and high network throughput

Spread

β€’ Pros:

β€’ Can span across Availability Zones (AZ)

β€’ Reduced risk is simultaneous failure

β€’ EC2 Instances are on different physical hardware

β€’ Cons:

β€’ Limited to 7 instances per AZ per placement group

β€’ Use case:

β€’ Application that needs to maximize high availability

β€’ Critical Applications where each instance must be isolated from failure from each other

Partition

β€’ Up to 7 partitions per AZ

β€’ Can span across multiple AZs in the same region

β€’ Up to 100s of EC2 instances

β€’ The instances in a partition do not share racks with the instances in the other partitions

β€’ A partition failure can affect many EC2 but won’t affect other partitions

β€’ EC2 instances get access to the partition information as metadata

β€’ Use cases: HDFS, HBase, Cassandra, Kafka

Elastic Network Interfaces (ENI)

β€’ Logical component in a VPC that represents a virtual network card

β€’ The ENI can have the following attributes:

β€’Primary private IPv4, one or more secondary IPv4

β€’ One Elastic IP (IPv4) per private IPv4

β€’ One Public IPv4

β€’ One or more security groups

β€’ A MAC address

β€’ You can create ENI independently and attach them on the fly (move them) on EC2 instances for failover

β€’ Bound to a specific availability zone (AZ)

EC2 Hibernate

β€’ We know we can stop, terminate instances

β€’ Stop – the data on disk (EBS) is kept intact in the next start

β€’ Terminate – any EBS volumes (root) also set-up to be destroyed is lost

β€’ On start, the following happens:

β€’ First start: the OS boots & the EC2 User Data script is run

β€’ Following starts: the OS boots up

β€’ Then your application starts, caches get warmed up, and that can take time!

β€’ Introducing EC2 Hibernate:

β€’ The in-memory (RAM) state is preserved

β€’ The instance boot is much faster! (the OS is not stopped / restarted)

β€’ Under the hood: the RAM state is written to a file in the root EBS volume

β€’ The root EBS volume must be encrypted

β€’ Use cases:

β€’ Long-running processing

β€’ Saving the RAM state

β€’ Services that take time to initialize

EC2 Hibernate – Good to know

β€’ Supported Instance Families – C3, C4, C5, I3, M3, M4, R3, R4, T2, T3, …

β€’ Instance RAM Size – must be less than 150 GB.

β€’ Instance Size – not supported for bare metal instances.

β€’ AMI – Amazon Linux 2, Linux AMI, Ubuntu, RHEL, CentOS & Windows…

β€’ Root Volume – must be EBS, encrypted, not instance store, and large

β€’ Available for On-Demand, Reserved and Spot Instances

β€’ An instance can NOT be hibernated more than 60 days

EC2 Nitro

β€’ Underlying Platform for the next generation of EC2 instances

β€’ New virtualization technology

β€’ Allows for better performance:

β€’ Better networking options (enhanced networking, HPC, IPv6)

β€’ Higher Speed EBS (Nitro is necessary for 64,000 EBS IOPS – max 32,000 on non-Nitro)

β€’ Better underlying security

β€’ Instance types example:

β€’ Virtualized:A1, C5, C5a, C5ad, C5d, C5n, C6g, C6gd, C6gn, D3, D3en, G4, I3en, Inf1, M5, M5a, M5ad, M5d, M5dn, M5n, ….

β€’ Bare metal: a1.metal, c5.metal, c5d.metal, c5n.metal, c6g.metal, c6gd.metal…

EC2 – Understanding vCPU

β€’ Multiple threads can run on one CPU (multithreading)

β€’ Each thread is represented as a virtual CPU (vCPU)

β€’ Example: m5.2xlarge

β€’ 4 CPU

β€’ 2 threads per CPU

β€’ => 8 vCPU in total

EC2 – Capacity Reservations

β€’ Capacity Reservations ensure you have EC2 Capacity when needed

β€’ Manual or planned end -date for the reservation

β€’ No need for 1 or 3 -year commitment

β€’ Capacity access is immediate, you get billed as soon as it starts

β€’ Specify:

β€’ The Availability Zone in which to reserve the capacity (only one)

β€’ The number of instances for which to reserve capacity

β€’ The instance attributes, including the instance type, tenancy, and platform/OS

β€’ Combine with Reserved Instances and Savings Plans to do cost saving

Last updated