Graduate Program KB

Section 2 - EC2

Same content! Refer to Section 03 - EC2

SAA Level EC2 Content

Private vs. Public IP

  • IPv4: 1.160.10.240, most commonly used format online
  • IPv6: 3ffe:1900:4545:3:200:f8ff:fe21:67cf, newer and solves issues for IoT
  • Public IP:
    • Machine can be identified on the internet
    • Unique across the whole web, machines can't share the same public IP
    • Can be geo-located easily
  • Private IP:
    • Machine can only be identified on a private network only
    • Unique across the private network (two different private networks can have the same IP)
    • Machines can connect to the internet using a NAT and internet gateway (proxy)
    • Only a specified range of IPs can be used as a private IP

Elastic IPs

  • When stopping and starting an EC2 instance, its public IP changes
    • An elastic IP provides a fixed public IP for your instance
    • The IP will be IPv4 and you will own it as long as it's not deleted
    • The IP can be attached to one instance at a time
  • The failure of an instance or software can be masked by rapidly remapping the address to another instance in your account
  • By default, you can only have 5 elastic IPs per account (can ask AWS to increase)
  • Try avoid elastic IPs for the following reasons:
    • Often reflect poor architectural decisions
    • Instead, use a random public IP and register a DNS name to it
    • Or use a load balancer and don't use a public IP

Placement Groups

  • Placement groups define control over your EC2 instance placement strategy
  • When creating a placement group, one of the following strategies are specified:
    • Cluster: Cluster instances into a low-latency group in a single AZ
    • Spread: Spreads instances across underlying hardware (max. 7 instances per group per AZ)
    • Partition: Spreads instances across many different partitions (relying on different sets of racks) within an AZ. It scales to 100s of EC2 instances per group (Hadoop, Cassandra, Kafka)

Cluster

  • 10 Gbps bandwidth between instances with Enhanced Networking enabled
  • If AZ fails then all instances fail at the same time
  • Useful for a big data job that needs fast completion or applications that need extremely low latency and high network throughput

Spread

  • Pros:
    • Span across multiple AZ, therefore reduced risk of failure
    • EC2 instances are on different physical hardware
  • Cons:
    • Limited to 7 instances per AZ per placement group
  • Use cases:
    • Applications that need high availability
    • Critical applications where each instance must be isolated from failure from each other

Partition

  • Can have up to 7 partitions per AZ, can span across multiple AZs in the same region
  • Up to 100s of EC2 instances
  • Instances in a partition don't share racks with instances in other partitions
    • A partition failure will only affect EC2 instances within it but not other partitions
    • EC2 instances get access to the partition information as metadata
  • Use cases: HDFS, HBase, Cassandra, Kafka

Elastic Network Interfaces

  • A logical component in a VPC that represents a virtual network card
  • Possible attributes of an ENI:
    • Primary private IPv4 and one or more secondary IPv4
    • An elastic IP per private IPv4
    • One public IPv4
    • One or more security groups
    • A MAC address
  • ENI can be created independently and attached onto EC2 instances for failover
  • Bounded to a specific AZ

EC2 Hibernate

  • Stopping instances: Data on disk (EBS) is kept intact on the next start
  • Terminating instances: Any root EBS volumes set-up to be destroyed are lost
  • Events of different startup processes of an EC2 instance:
    • Initial start: OS boots and EC2 user data script is ran
    • Other starts: OS boots up then application starts, caches take time to warm up
  • With EC2 Hibernate:
    • In-memory (RAM) state is preserved
    • Instance boot is much faster
    • What happens is 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 initialise
  • Other details of EC2 Hibernate:
    • Supported instance families: C3, C4, C5, I3, M3, M4, R3, R4, T2, T3, etc.
    • Instance RAM size must be less than 150 GB
    • Instance size is not supported for bare metal instances
    • AMI: Amazon Linux 2, Linux AMI, Ubuntu, RHEL, CentOS, Windows, etc.
    • Root volume must be EBS, encrypted, large and it can't be an instance store
    • Available for On-Demand, Reserved and Spot instances
    • An instance can't be hibernated for more than 60 days