AWS Certified Solutions Architect - Note (5)

Elastic Compute Cloud (EC2)

EC2 Instance Types

EC2 Instance Sizes

EC2 Instance Profiles

EC2 Placement Groups

EC2 UserData

EC2 MeataData

EC2 CheatSheet

  • Elastic Compute Cloud (EC2) is a Cloud Computing Service.
  • Configure your EC2 by choosing your OS, Storage, Memory, Network Throughput.
  • Launch and SSH into your server within minutes.
  • EC2 comes in variety Instance Types specialized for different roles:
    • General Purpose balance of compute, memory and networking resources.
    • Compute Optimized Ideal for compute bound applications that benefit from high performance processor.
    • Memory Optimized fast performance for workloads that process large data sets in memory.
    • Accelerated Optimized hardware accelerators, or co-processors.
    • Storage Optimized high, sequential read and write access to very large data sets on local storage
  • Instance Sizes generally double in price and key attributes.
  • Placement Groups let you to choose the logical placement of your instances to optimize for communication, performance or durability. Placement groups are free.
  • UserData a script that will be automatically run when launching an EC2 instance.
  • MetaData meta data about the current instance. You access this meta data via a local endpoint when SSH’d into the EC2 instance. eg. curl http://169.254.169.254/Iatest/meta-data meta data could be the instance type, current ip address etc…
  • Instance Profiles a container for an IAM role that you can use to pass role information to an EC2 instance when the instance starts.

EC2 Pricing Models

EC2 On-Demand Instances

EC2 Reserved Instances(RI)

EC2 Spot Instances

EC2 Dedicated Host Instances

EC2 Pricing CheatSheet

  • EC2 has for 4 pricing models On-Demand, Spot, Reserved Instances (RI) and Dedicated.
  • On-Demand (least commitment)
    • low cost and flexible
    • only pay per hour
    • Use case: short-term, spiky, unpredictable workloads, first time apps
    • Ideal when your workloads cannot be interrupted
  • Reserved Instances upto 75% off (Best long-term value)
    • Use case: steady state or predictable usage
    • Can resell unused reserved instances (Reserved Instance Marketplace)
    • Reduced Pricing is based on Term x Class Offering x Payment Option
    • Payment Terms: 1 year or 3 year
    • Payment Options: All Upfront, Partial Upfront, and No Upfront
    • Class Offerings
      • Standard Up to 75% reduced pricing compared to on-demand. Cannot change RI Attributes.
      • Convertible Up to 54% reduced pricing compared to on-demand. Allows you to change RI Attributes if greater or equal in value.
      • Scheduled You reserve instances for specific time periods eg. once a week for a few hours. Savings vary
  • Spot Pricing upto 90% off (Biggest Savings)
    • request spare computing capacity
    • flexible start and end times
    • Use case: Can handle interruptions (server randomly stopping and starting)
    • Use case: For non-critical background jobs
    • Instances can be terminated by AWS at anytime
    • If your instance is terminated by AWS, you don’t get charged for a partial hour of usage.
    • If you terminate an instance you will still be charged for any hour that it ran.
  • Dedicated Hosting (Most Expensive)
    • Dedicated servers
    • Can be on-demand or reserved (upto 70% off)
    • Use case: When you need a guarantee of isolate hardware (enterprise requirements)

Amazon Machine Image (AMI)

AMI Use Case

AMI Marketplace

Creating an AMI

Choosing an AMI

Copying an AMI

AMI CheatSheet

  • Amazon Machine Image (AMI) provides the information required to launch an instance.
  • AMIS are region specific, if you need to use an AMI in another region you can copy an AMI into the destination region via Copy AMI.
  • You can create an AMI from an existing EC2 instance that’s either running or stopped.
  • Community AMI are free AMIs maintained by the community.
  • AWS Marketplace free or paid subscription AMIs maintained by vendors.
  • AMIs have an AMI ID. The same AMI eg. (Amazon Linux 2) will vary in both AMI ID and options eg. Architecture options in different regions.
  • An AMI holds the following information:
    • A template for the root volume for the instance (EBS Snapshot or Instance Store template) eg. an operating system, an application server, and applications.
    • Launch permissions that control which AWS accounts can use the AMI to launch instances.
    • A block device mapping that specifies the volumes to attach to the instance when it’s launched.

Auto Scaling Groups

ASG Capacity Settings

ASG Health Check Replacements

ASG Scaling Policies

ASG ELB Integration

ASG ELB Integration

ASG Launch Configuration

EC2 Auto Scaling Groups CheatSheet

  • An ASG is a collection of EC2 instances grouped for scaling and management.
  • Scaling Out is when add servers.
  • Scaling In is when you remove servers.
  • Scaling Up is when you increase the size of an instance. (eg. updating Launch Configuration with larger size)
  • Size of an ASG is based on a Min, Max and Desired Capacity.
  • Target Scaling policy scales based on when a target value for a metric is breached eg. Average CPU Utilization exceed 75%.
  • Simple Scaling policy triggers a scaling when an alarm is breached.
  • Scaling Policy with Steps is the new version of Simple Scaling policy and allows you to create steps based on escalation alarm values.
  • Desired Capacity is how many EC2 instances you want to ideally run.
  • An ASG will always launch instances to meet minimum capacity.
  • Health checks determine the current state of an instance in the ASG.
  • Health checks can be run against either an ELB or the EC2 instances.
  • When an Autoscaling launches a new instance it uses a Launch Configuration which holds the configuration values for that new instance eg. AMI, InstanceType, Role
  • Launch Configurations cannot be edited and must be cloned or a new one created.
  • Launch Configurations must be manually updated in by editing the Auto Scaling settings.

Elastic Load Balancer (ELB)

ELB The Rule of Traffic

Application Load Balancer (ALB)

Network Load Balancer (NLB)

Classic Load Balancer (CLB)

ELB Sticky Sessions

X-Forwarded-For(XFF) Header

ELB Health Checks

ELB-Cross-Zone Load Balancing

ALB Request Routing

ELB CheatSheet

  • There are three Elastic Load Balancers: Network, Application and Classic Load Balancer.
  • A Elastic Load Balancer must have at least two Availability Zones.
  • Elastic Load Balancers cannot go cross-region. You must create one per region.
  • ALB has Listeners, Rules and Target Groups to route traffic.
  • NLB use Listeners and Target Groups to route traffic.
  • CLB use Listeners and EC2 instances are directly registered as targets to CLB.
  • Application Load Balancer is for HTTP(S) traffic and the name implies it good for Web Applications.
  • Network Load Balancer is for TCP/UDP is good for high network throughput eg. Video Games
  • Classic Load Balancer is legacy and its recommended to use ALB or NLB.
  • Use X-Forwarded-For (XFF) to get original IP of incoming traffic passing through ELB
  • You can attach Web Application Firewall (WAF) to ALB but not to NLB or CLB.
  • You can attach Amazon Certification Manager SSL to any of the Elastic Load Balancers for SSL.
  • ALB has advanced Request Routing rules where you can route based on subdomain header, path and other HTTP(S) information.
  • Sticky Sessions can be enable for CLB or ALB and sessions are remembered via Cookie.

Elastic File System (EFS)

EFS CheatSheet

  • Elastic File System (EFS) supports the Network File System version 4 (NFSv4) protocol.
  • You pay GB of storage per month.
  • Volumes can scale to petabyte size storage.
  • Volumes will shrink and grow to meet current data stored (elastic).
  • Can support thousands of concurrent connections over NFS.
  • Your data is stored across multiple AZs within a region.
  • Can mount multiple EC2 instance to a single EFS (as long as they are all in the same VPC)
  • Creates Mount Points in all your VPC subnets so you can mount from anywhere within your VPC.
  • Provides Read After Write Consistency.

Elastic Block Store (EBS)

EBS Volume Type Usage

Storage Volumes

EBS Moving Volumes

EBS Encrypted Root Volume

EBS Vs Instance Storage Volumes

EBS CheatSheet

  • Elastic Block Store (EBS) is a virtual hard disk. Snapshots are a point-in-time copy of that disk.
  • Volumes exist on EBS. Snapshots exist on S3.
  • Snapshots are incremental, only changes made since the last snapshot are moved to S3.
  • Initial Snapshots of an EC2 instance will take longer to create than subsequent Snapshots
  • If taking Snapshot of a root volume, the EC2 instance should be stopped before Snapshotting.
  • You can take Snapshots while the instance is still running.
  • You can create AMIS from Volumes, or from Snapshots.
  • EBS Volumes A durable, block-level storage device that you can attach to a single EC2 instance
  • EBS Volumes can be modified on the fly eg. storage type or volume size.
  • Volumes always exist in the same AZ as the EC2 instance.
  • Instance Store Volumes A temporary storage type located on disks that are physically attached to a host machine.
  • Instance Store Volumes (ephemeral) cannot be stopped. If the host fails then you lose your data.
  • EBS Backed instances can be stopped and you will not lose any data.
  • By default root volumes are deleted on termination.
  • EBS Volumes can have termination protection (don’t delete the volume on termination)
  • Snapshots or restored encrypted volumes will also be encrypted.
  • You cannot share a snapshot if it has been encrypted.
  • Unencrypted snapshots can be shared with other AWS accounts or made public.
comments powered by Disqus