AWS Cloud Foundations
LinkedIn
  • Intro
  • Module 1
  • Module 2
  • Module 3
  • Module 4
  • Module 5
  • Module 6
  • Module 7
  • Module 8
  • Module 9
  • Module 10
Powered by GitBook
On this page
  • AWS Compute Services
  • Categorizing compute services
  • Choosing the optimal compute service
  • Amazon Elastic Compute Cloud (Amazon EC2)
  • Launching an Amazon EC2 instance
  • Amazon EC2 instance lifecycle
  • Amazon CloudWatch for monitoring
  • Some Takeaways
  • Amazon EC2 pricing models
  • Benefits and Use Cases for Each Model
  • The Four Pillars of Cost Optimization
  • Containers
  • What is Docker
  • Amazon Elastic Container Service (Amazon ECS)
  • AWS Lambda
  • Some Takeaways
  • AWS Elastic Beanstalk

Module 6

PreviousModule 5NextModule 7

Last updated 12 months ago

AWS Compute Services

Categorizing compute services

Choosing the optimal compute service

Choosing the most optimal compute service really just depends on what you will be using it for

Some aspects to consider:

  • What is your application design?

  • What are your usage patterns?

  • Which configuration settings will you want to manage?

Selecting the wrong compute solution for an architecture can lead to lower performance efficiency

Amazon Elastic Compute Cloud (Amazon EC2)

Amazon EC2 can almost host anything

Examples:

  • Application servers

  • Web servers

  • Database servers

  • Game servers

  • Mail servers

  • Media servers

  • Catalog servers

  • File servers

  • Computing servers

  • Proxy servers

Launching an Amazon EC2 instance

  1. Select an AMI (Amazon Machine Image)

An AMI is a template that is used to create an EC2 instance, Windows or Linux and often also has some software-installed

  1. Select an instance type

Instance types comprise varying combinations of CPU, memory, storage, and networking capacity.

Instance type categories:

  • General purpose

  • Compute optimized

  • Memory optimized

  • Storage optimized

  • Accelerated computing

Network bandwidth can also be configured (up to 100 gbps)

EC2 instance type naming and sizes

Example: t3.large

  • T is the family

  • 3 is the generation

  • Large is the size

  1. Specify network settings

  1. Attach IAM role (optional)

Will software on the EC2 instance need to interact with other AWS services? If yes, attach an appropriate IAM Role.

An AWS Identity and Access Management (IAM) role that is attached to an EC2 instance is kept in an instance profile

You can also attach a role to an instance that already exists

  1. User data script (optional)

You can place a script that will automatically install a webserver or specific packages on instance launch for example.

"A script that is going to be executed when an instance is created"

  1. Specify Storage

Configure the root volume where the guest os will be installed. You can also attach additional storage volumes.

Each volume must have the following specified:

  • The size of the disk (in GB)

  • The volume type

  • Different types of solid-state drives (SSDs) and hard disk drives (HDDs) are available

  • If the volume will be deleted when the instance is terminated

  • If encryption should be used

Amazon EC2 storage options

  • Amazon Elastic Block Store (Amazon EBS)

    • Durable, block-level storage volumes.

    • You can stop the instance and start it again, and the data will still be there

  • Amazon EC2 Instance Store

    • Ephemeral storage is provided on disks that are attached to the host computer where the EC2 instance is running.

    • If the instance stops, the data stored here is deleted

  • Other (not for root volume)

    • Mount an Amazon Elastic File System (Amazon EFS) file system.

    • Connect to Amazon Simple Storage Service (Amazon S3)

You can increase the size of an EBS but you can't decrease it

Example storage options

  1. Add tags

Tags are labels that are used to groups elements and filter elements. They are key value pairs

  1. Security Group Settings

  1. Identify or create a key pair (just generating an ssh key pair)

Amazon CLI instance creation

aws ec2 run-instances \--image-id ami-1a2b3c4d \--count 1 \--instance-type c3.large \--key-name MyKeyPair \--security-groups MySecurityGroup \--region us-east-1

Amazon EC2 instance lifecycle

Rebooting an instance will not change any IP addresses or DNS hostnames BUT when an instance is stopped and then started again the public IP and hostname will change

You can use an Elastic IP address with an instance to have a persistent public IP address

EC2 instance metadata and user-data can be seen with the following URL

http://169.254.169.254/latest/meta-data/
http://169.254.169.254/latest/user-data/

Amazon CloudWatch for monitoring

Amazon CloudWatch is used to monitor EC2 instances. It provides near-real-time metrics, maintains 15 months of historical data, and a cool dashboard full of charts :D

  • Basic monitoring is the default, comes with no costs and updates every 5 minutes

  • Detailed monitoring is a fixed monthly rate for 7 pre-selected metrics, updates every 1 minute

Some Takeaways

  • Amazon EC2 enables you to run Windows and Linux virtual machines in the cloud.

  • You launch EC2 instances from an AMI template into a VPC in your account.

  • You can choose from many instance types. Each instance type offers different combinations of CPU, RAM, storage, and networking capabilities.

  • You can configure security groups to control access to instances (specify allowed ports and source).

  • User data enables you to specify a script to run the first time that an instance launches.

  • Only instances that are backed by Amazon EBS can be stopped.

  • You can use Amazon CloudWatch to capture and review metrics on EC2 instances.

Amazon EC2 pricing models

Benefits and Use Cases for Each Model

The Four Pillars of Cost Optimization

  • Right size

    • Provision instances to match your needs

    • CPU, memory, storage, and network throughput

    • Select appropriate instance types for your use

    • Watch metrics on Amazon CloudWatch

Best practice: Right size, then reserve

  • Increase elasticity

    • Stop or hibernateAmazon EBS-backed instances that are not actively in use ( non-production development or test instances )

    • Use automatic scaling to match needs based on usage

  • Optimal pricing model

    • Use the right pricing model for your use case and combine purchase types to fully optimize

    • Use On-Demand Instance and SpotInstancesfor variable workloads

    • Use Reserved Instances for predictable workload

You could probably also use AWS Lambda (functions) for some tasks

  • Optimize storage choices

    • Reduce costs while maintaining storage performance and availability

    • Save money by resizing EBS volumes, changing volume types, deleting EBS snapshots that are no longer needed

  • Amazon S3 storage options with lifecycle policies can reduce costs

Defining and enforcing cost allocation tagging can help improve costs

Containers

  • Repeatable

  • Self-Contained environement

  • Software runs the same in different environements

  • Faster to launch and stop than VMs

Containers are often compared to virtual machines (VMs). Like virtual machines, containers allow you to package your application together with libraries and other dependencies, providing isolated environments for running your software services

~ Google Cloud

What is Docker

  • Orchestrates the running of Docker containers

  • Maintains and scales the fleet of nodes that run your containers

  • Removes the complexity of standing up the infrastructure

AWS Lambda

  • It supports multiple programming languages

  • Completely automated administration

  • Built-infault tolerance supports the orchestration of multiple functions

  • Pay-per-use pricing

Some Takeaways

  • Serverless computing enables you to build and run applications and services without provisioning or managing servers.

  • AWS Lambda is a serverless compute service that provides built-in fault tolerance and automatic scaling.

  • An event source is an AWS service or developer-created application that triggers a Lambda function to run.

  • The maximum memory allocation for a single Lambda function is 10,240 MB.

  • The maximum run time for a Lambda function is 15 minutes

AWS Elastic Beanstalk

  • It supports web applications written for common platforms: Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker

  • You upload your code

    • Elastic Beanstalk automatically handles the deployment

    • Deploys on servers such as Apache, NGINX, Passenger, Puma, and Microsoft Internet Information Services (IIS)

Amazon Elastic Container Service (Amazon ECS)