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