0% found this document useful (0 votes)
89 views

Week 7 - AcademyCloudFoundations_Module_06 - Compute

The document discusses AWS Academy Cloud Foundations, focusing on Amazon EC2 cost optimization and AWS Lambda. It outlines various EC2 pricing models, their benefits, and use cases, along with the four pillars of cost optimization: right sizing, increasing elasticity, optimal pricing models, and optimizing storage choices. Additionally, it introduces AWS Lambda as a serverless compute service, highlighting its features, benefits, and pricing structure.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
89 views

Week 7 - AcademyCloudFoundations_Module_06 - Compute

The document discusses AWS Academy Cloud Foundations, focusing on Amazon EC2 cost optimization and AWS Lambda. It outlines various EC2 pricing models, their benefits, and use cases, along with the four pillars of cost optimization: right sizing, increasing elasticity, optimal pricing models, and optimizing storage choices. Additionally, it introduces AWS Lambda as a serverless compute service, highlighting its features, benefits, and pricing structure.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 65

AWS Academy Cloud Foundations

Module 6: Compute
Module 6: Compute

Section 3: Amazon EC2 cost optimization


Amazon EC2 pricing models

On-Demand Instances Reserved Instances Spot Instances


• Pay by the hour • Full, partial, or no upfront payment • Instances run as long as they are
for instance you reserve. available and your bid is above the
• No long-term commitments. Spot Instance price.
• Discount on hourly charge for that
• Eligible for the AWS Free Tier. instance. • They can be interrupted by AWS
with a 2-minute notification.
• 1-year or 3-year term.
Dedicated Hosts • Interruption options include
terminated, stopped or hibernated.
• A physical server with EC2 instance
capacity fully dedicated to your use. Scheduled Reserved • Prices can be significantly less
Instances expensive compared to On-
Demand Instances
• Purchase a capacity reservation
Dedicated Instances that is always available on a
• Good choice when you have
recurring schedule you specify. flexibility in when your applications
• Instances that run in a VPC on can run.
hardware that is dedicated to a • 1-year term.
single customer.
Per second billing available for On-Demand Instances, Reserved Instances, and
Spot Instances that run Amazon Linux or Ubuntu.
3
Amazon EC2 pricing models: Benefits

On-Demand Instances Spot Instances Reserved Instances Dedicated Hosts


• Low cost and • Large scale, dynamic • Predictability ensures • Save money on
flexibility workload compute capacity is licensing costs
available when • Help meet compliance
needed and regulatory
requirements

4
Amazon EC2 pricing models: Use
cases

Spiky Workloads Time-Insensitive Steady-State Workloads Highly Sensitive


Workloads Workloads

On-Demand Instances Spot Instances Reserved Instances Dedicated Hosts


• Short-term, spiky, or • Applications with flexible • Steady state or predictable • Bring your own license
unpredictable workloads start and end times usage workloads (BYOL)
• Application development or • Applications only feasible at • Applications that require • Compliance and regulatory
testing very low compute prices reserved capacity, including restrictions
• Users with urgent computing disaster recovery
needs for large amounts of • Users able to make upfront • Usage and licensing tracking
additional capacity payments to reduce total • Control instance placement
computing costs even further

5
Spot Instance
Spot Instance Pricing
• Here is an example pricing taken in
August 2020 in the London Region

https://aws.amazon.com/ec2/spot/pricing/
Spot Instance
• Here are the values in March 2020 during the COVID-19 Virus
outbreak where Cloud computing did see an increase in usage

• You will notice that the


SPOT price is still quite
stable from the previously
seen figures

https://aws.amazon.com/ec2/spot/pricing/
The four pillars of cost optimization
Cost Optimization

Increase Optimal Optimize


Right size
elasticity pricing storage
model choices

9
Pillar 1: Right size

Pillars ✔Provision instances to match the need


: 1. Right size ▶
▶ • CPU, memory, storage, and network throughput
2. Increase elasticity • Select appropriate instance types for your use
3. Optimal pricing model
4. Optimize storage choices ✔Use Amazon CloudWatch metrics
• How idle are instances? When?
• Downsize instances

✔Best practice: Right size, then reserve

10
Pillar 2: Increase elasticity

✔Stop or hibernate Amazon EBS-backed


Pillars instances that are not actively in use
: 1. Right-Size • Example: non-production development or test

3. Optimal pricing model



2. Increase Elasticity ▶ instances

4. Optimize storage choices


✔Use automatic scaling to match needs based
on usage
• Automated and time-based elasticity

11
Pillar 3: Optimal pricing model

Pillars ✔Leverage the right pricing model for your use


: 1. Right-Size case
2. Increase Elasticity
• Consider your usage patterns

3. Optimal pricing model ▶
4. Optimize storage choices
✔Optimize and combine purchase types
✔Examples:
• Use On-Demand Instance and Spot Instances for
variable workloads

• Use Reserved Instances for predictable workloads

✔Consider serverless solutions (AWS Lambda)


12
Pillar 4: Optimize storage choices

✔ Reduce costs while maintaining storage performance and


Pillars availability
: 1. Right-Size ✔ Resize EBS volumes
2. Increase Elasticity
3. Optimal pricing model ✔ Change EBS volume types
4. Optimize storage choices ▶▶ ✔ Can you meet performance requirements with less expensive
storage?
✔ Example: Amazon EBS Throughput Optimized HDD (st1) storage
typically costs half as much as the default General Purpose SSD
(gp2) storage option.

✔ Delete EBS snapshots that are no longer needed

✔ Identify the most appropriate destination for specific types


of data
✔ Does the application need the instance to reside on Amazon EBS?
✔ Amazon S3 storage options with lifecycle policies can reduce costs
13
Measure, monitor, and improve

• Cost optimization is an ongoing process.

• Recommendations –
• Define and enforce cost allocation tagging.

• Define metrics, set targets, and review regularly.

• Encourage teams to architect for cost.

• Assign the responsibility of optimization to an individual or to


a team.

14
• Amazon EC2 pricing models include On-
Section 3 key Demand Instances, Reserved Instances, Spot
Instances, Dedicated Instances, and Dedicated
takeaways Hosts.

• Spot Instances can be interrupted with a 2-


minute notification. However, they can offer
significant cost savings over On-Demand
Instances.

• The four pillars of cost optimization are:


• Right size
• Increase elasticity
• Optimal pricing model
• Optimize storage choices

15
Module 6: Compute

Section 5: Introduction to AWS Lambda

16
What is AWS Lambda?

• Fully managed serverless compute


• Event-driven execution
• Sub-second metering

AWS • billed in chunks of 1ms !


Lambda • Function execution limited to a maximum of
15 minutes
• Multiple languages supported
What is AWS Lambda?

AWS
Lambda
What is AWS Lambda?

AWS
Lambda
What is AWS Lambda?
• Traditional Client/Server
• it does not matter if this is EC2 or a physical instance
What is AWS Lambda?
• What you need to do is predict the
maximum usage of the function which
is on the server
• you then specify the device
accordingly
What is AWS Lambda?
• In Lambda this is a virtual server which simply provides the service

AWS
Lambda
What is AWS Lambda?
• As always if no one uses the service then you pay NOTHING

AWS
Lambda
What is AWS Lambda?
• In addition you do not need to predict your limits
• Lambda will simply scale to whatever you need

AWS
Lambda
Lambda Key Benefits

No Servers Continuous Sub-second


to Manage Scaling Metering
(1ms)
AWS Lambda: Run code without
servers
AWS Lambda is a serverless compute service.

The code you run


is a Lambda function
Upload your code

AWS HTTP
services endpoints Your code Pay only for the
Mobile apps
runs only when compute time
Run your code on a schedule
it is that
or in response to events
triggered you use

26
Benefits of Lambda

It supports multiple programming languages


Completely automated administration
Built-in fault tolerance
AWS It supports the orchestration of multiple functions
Lambda
Pay-per-use pricing

27
AWS Lambda event sources
Event sources Configure other AWS services as event sources to
invoke your function as shown here.

Amazon Alternatively, invoke a Lambda function from the


S3 Lambda console, AWS SDK, or AWS CLI.
Amazon
DynamoDB
Amazon Simple Notification
Service (Amazon SNS)
Lambda Execution of your code
Amazon Simple Queue function (only when triggered)
Service (Amazon SQS)
AWS Lambda
Amazon API
Gateway Logging,
monitoring, and
Application Load metrics
Balancer Amazon
Many more… CloudWatch

28
Lambda Pricing
● To encourage the use of Lambda a lot of resources are provided
for free
○ 1 Million requests per month
○ 400,000 GB-seconds per month free
■ This can equate to 3.2 million seconds of compute time
■ It will depend on the amount of RAM you require for the
function
○ https://docs.aws.amazon.com/whitepapers/latest/how-aws-pric
ing-works/lambda.html

● In small to medium sized companies it is perfectly possible that


this is a free resource
Example Company
• An example here from Coca Cola and vending machines
• As a cost alone the original system was costing $13,000 and using Lambda the
costs reduced to $4,500 per year
Lambda Pricing
● Lambda is a very powerful technology
○ Due to its flexibility it is widely used
○ It does need to be considered though
■ if you have a function which is going to be
running 15 minutes 24/7 then it may be
cheaper to run this on an EC2 unit
● If you need a server which you can not
predict the usage and is not running all of
the time then Lambda is a better
environment
○ You can use this website to give you
an indication of costs
○ https://servers.lol/
○ in the case given here
■ Lambda costs are $0.40
■ EC2 Costs are $69.12
● https://dashbird.io/lambda-cost-calculator/
Event-based Lambda function example:
Create thumbnail images
AWS Cloud
1
2 3

User

Source Lambda 4
bucket
Execution
5
role
Access
policy
Target
bucket Lambda
function
34
LAMBDA - RAM/CPU
• To use this you are simply providing
• The code you want to run
• Defining the amount of RAM your function will require
• The CPU is allocated automatically based on the amount of RAM you allocate
• Upto a maximum of 6 vCPUs

https://aws.amazon.com/blogs/aws/new-for-aws-lambda-
functions-with-up-to-10-gb-of-memory-and-6-vcpus/
AWS Lambda limits

Soft limits per Region:


• Concurrent executions = 1,000
• Function and layer storage = 75 GB

Hard limits for individual functions:


• Maximum function memory allocation = 10 Gbytes
• Function timeout = 15 minutes
• Deployment package size = 250 MB unzipped, including layers

Additional limits also exist. Details are in the AWS Lambda Limits documentation.
36
• Serverless computing enables you to build
Section 5 key and run applications and services without
takeaways 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 3,008 MB.

• The maximum execution time for a Lambda


function is 15 minutes.
37
Activity: Create an To complete this activity:
AWS Lambda
Stopinator Function • Go to the hands-on lab environment
and launch the AWS Lambda activity.

• Follow the instructions that are


provided in the hands-on lab
environment.

Photo by Pixabay from Pexels.

38
Module 6: Compute

Section 4: Container services


Container basics

• Containers are a method of


Your Container
operating system virtualization.
Your application
• Benefits –
• Repeatable.
• Self-contained execution environments. Dependencies

• Software runs the same in different


environments. Configurations
• Developer's laptop, test, production.
• Faster to launch and stop or terminate Hooks into OS
than virtual machines

40
What is Docker?

• Docker is a software platform


that enables you to build, test, Container
and deploy applications quickly.
• You run containers on Docker. Containers have everything the
• Containers are created from a software needs to run:
template called an image.
• A container has everything a System
Libraries Code Runtime
software application needs to tools

run.

41
Containers versus virtual machines
Three virtual machines on three EC2 instances
Example
VM 1 VM 2 VM 3
Three containers on one EC2 instance Container
App 1 App 2 App 3
Container Container Container
instance 1 Bins/Libs Bins/Libs Bins/Libs
instance 2 instance 3

Docke App 1 App 2 App 3 EC2 EC2 EC2


r
instance instance instance
engine Bins/Libs Bins/Libs Bins/Libs guest guest guest
OS OS OS
EC2 instance guest OS

Hypervisor
Part of
Host operating system AWS Global
Infrastructure
Physical server
42
What is a Container
• Here is a link to a video which VMWare discuss the
use of Containers to help to understand

43
What is ECS for Docker

• Quick discussion Video

44
Amazon Elastic Container Service
(Amazon ECS)
• Amazon Elastic Container Service (Amazon ECS) –
• A highly scalable, fast, container management service

• Key benefits – Amazon Elastic


Container Service
• Orchestrates the execution of Docker containers
• Maintains and scales the fleet of nodes that run your containers
• Removes the complexity of standing up the infrastructure

• Integrated with features that are familiar to Amazon EC2 service users –
• Elastic Load Balancing
• Amazon EC2 security groups
• Amazon EBS volumes
• IAM roles
45
Amazon ECS orchestrates containers

EC2 instance
Requests to run containers
x3 x2

Container A
EC2 instance

Container B
Amazon Elastic Container
Service (Amazon ECS)

ECS cluster 46
Amazon ECS cluster options
• Key question: Do you want to manage the Amazon ECS cluster that runs the
containers?

• If yes, create an Amazon ECS cluster backed by Amazon EC2 (provides more granular
control over infrastructure)
• If no, create an Amazon ECS cluster backed by AWS Fargate (easier to maintain, focus on
your applications) Containers
Amazon ECS Container Container Container Amazon ECS
cluster backed instance 1 instance 2 instance 3 cluster backed by
by Amazon EC2 Fargate
App 1 App 2 App 3
You manage
Bins/Libs Bins/Libs Bins/Libs
You manage
Docker engines (one per OS in the cluster)
AWS
VM guest operating systems in the Amazon ECS cluster manages

47
FarGate

• Quick Video

48
What is Kubernetes?

• Kubernetes is open source software for container orchestration.


• Deploy and manage containerized applications at scale.
• The same toolset can be used on premises and in the cloud.
• Complements Docker.
• Docker enables you to run multiple containers on a single OS host.
• Kubernetes orchestrates multiple Docker hosts (nodes).
• Automates –
• Container provisioning.
• Networking.
• Load distribution.
• Scaling.
49
Amazon Elastic Kubernetes Service
(Amazon EKS)
• Amazon Elastic Kubernetes Service (Amazon EKS)
• Enables you to run Kubernetes on AWS
• Certified Kubernetes conformant (supports easy migration)
• Supports Linux and Windows containers Amazon Elastic
Kubernetes Service
• Compatible with Kubernetes community tools and supports
popular Kubernetes add-ons

• Use Amazon EKS to –


• Manage clusters of Amazon EC2 compute instances
• Run containers that are orchestrated by Kubernetes on
those instances

50
Amazon Elastic Container Registry
(Amazon ECR)
Amazon ECR is a fully managed Docker container
registry that makes it easy for developers to store,
manage, and deploy Docker container images. Amazon ECS integration

Docker support

Team collaboration

Amazon Elastic
Container Registry Access control

Third-party integrations
Image Registry

51
• Containers can hold everything that an
Section 4 key application needs to run.

takeaways • Docker is a software platform that packages


software into containers.
• A single application can span multiple containers.
• Amazon Elastic Container Service (Amazon
ECS) orchestrates the execution of Docker
containers.
• Kubernetes is open source software for
container orchestration.
• Amazon Elastic Kubernetes Service (Amazon
EKS) enables you to run Kubernetes on AWS
• Amazon Elastic Container Registry (Amazon
ECR) enables you to store, manage, and deploy
your Docker containers.

52
Module 6: Compute

Section 6: Introduction to AWS Elastic Beanstalk


What is Elastic Beanstalk?

AWS
Elastic
Beanstalk
AWS Elastic Beanstalk

• An easy way to get web applications up and running

• A managed service that automatically handles –


• Infrastructure provisioning and configuration
• Deployment
• Load balancing
• Automatic scaling
AWS Elastic • Health monitoring
Beanstalk • Analysis and debugging
• Logging

• No additional charge for Elastic Beanstalk


• Pay only for the underlying resources that are used
• Platform As A Service (PAAS) 55
AWS Elastic Beanstalk deployments

• It supports web applications


written for common platforms
• Java, .NET, PHP, Node.js,
You Your code
Python, Ruby, Go, and Docker manage
HTTP server

• You upload your code Application server


AWS Language interpreter
• Elastic Beanstalk automatically manages
handles the deployment Operating system
• Deploys on servers such as Host
Apache, NGINX, Passenger,
Puma, and Microsoft Internet
Information Services (IIS)

56
What is Elastic Beanstalk?

• Platform as a Service (PaaS)


• Quickly deploys, scales, and manages web
apps
• Reduces management complexity
• Keeps control in your hands:
• Choose your instance type
• Choose your database
AWS
• Set ant adjust Auto Scaling
Elastic • Update your application
Beanstalk • Access server log files
• Enable HTTPS on load balancer
Benefits of Elastic Beanstalk

Fast and simple to Developer Difficult to Complete resource


start using productivity outgrow control

58
To complete this activity:
Activity: AWS
Elastic Beanstalk • Go to the hands-on lab environment
and launch the AWS Elastic Beanstalk
activity.

• Follow the instructions that are


provided in the hands-on lab
environment.

59
Activity debrief:

Key takeaways

60
• AWS Elastic Beanstalk enhances
Section 6 key developer productivity.
takeaways • Simplifies the process of deploying your
application.
• Reduces management complexity.

• Elastic Beanstalk supports Java, .NET,


PHP, Node.js, Python, Ruby, Go, and
Docker

• There is no charge for Elastic


Beanstalk. Pay only for the AWS
resources that you use.

61
Module 6: Compute

Module wrap-up
Module summary

In summary, in this module, you learned how to:


• Provide an overview of different AWS compute services in the cloud
• Demonstrate why to use Amazon Elastic Compute Cloud (Amazon EC2)
• Identify the functionality in the Amazon EC2 console
• Perform basic functions in Amazon EC2 to build a virtual computing environment
• Identify Amazon EC2 cost optimization elements
• Demonstrate when to use AWS Elastic Beanstalk
• Demonstrate when to use AWS Lambda
• Identify how to run containerized applications in a cluster of managed servers

63
Complete the knowledge check

64
Sample exam question

Which AWS service helps developers quickly deploy resources which


can make use of different programming languages, such as .NET and
Java?

A. AWS CloudFormation

B. AWS SQS

C. AWS Elastic Beanstalk

D. Amazon Elastic Compute Cloud (Amazon EC2)

65
Additional resources

• Amazon EC2 Documentation


• Amazon EC2 Pricing
• Amazon ECS Workshop
• Running Containers on AWS
• Amazon EKS Workshop
• AWS Lambda Documentation
• AWS Elastic Beanstalk Documentation
• Cost Optimization Playbook

66
Thank you

This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon Web Services, Inc. Commercial copying, lending, or
selling is prohibited. Corrections or feedback on the course, please email us at: [email protected]. For all other questions, contact us at:
https://aws.amazon.com/contact-us/aws-training/. All trademarks are the property of their owners.

You might also like