AWS
Compute
Lab
2
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Question Where do you run the majority of your
compute workloads?
A. On-premises physical or virtual
servers
B. Cloud-based servers
C. On-premises containers
D. Cloud-based containers
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Module overview
• Business request
• Compute services
• Amazon Elastic Compute Cloud (Amazon EC2) instances
• EC2 instance storage
• Amazon EC2 pricing options
• AWS Lambda
• Present solutions
• Knowledge check
• Capstone check-in
• Lab 2: Build your Amazon VPC infrastructure
Business The compute operations manager
wants to know:
Requirements
• What AWS compute services are
there?
• What should the team consider when
deploying new and existing servers to
Amazon EC2?
• How do we know which volume type
to attach to our EC2 instances?
Compute • How can we optimize cost for compute
Operations resources?
Manager
• Where can we start with serverless
compute options?
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Compute services
“What AWS compute services are there?”
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Evolution of AWS compute
AWS
Amazon Elastic Inferentia AWS
Container Service and Trainium Graviton
Amazon EC2 (Amazon ECS) AWS Lambda AWS Fargate processors processors
2006 2014 2014 2017 2021 2022
Virtualization Containerization Serverless Serverless AWS custom-built and
containerization specialized processors
AWS services in this module
Amazon Elastic Compute
Cloud (Amazon EC2)
Amazon Elastic Block Store
(Amazon EBS)
AWS Lambda
We will cover other compute-related services later in this
course.
EC2 instances
“What should the team consider when deploying new and
existing servers to Amazon EC2?”
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
EC2 instances
Physical servers EC2 instances give You can add or
host EC2 instances you secure and remove compute
in AWS Regions resizable compute capacity to meet
around the world. capacity in the changes in demand.
cloud.
EC2 instance launch considerations
Application and Instance type and
Name and tags Key pair
OS image size
Network and Placement and Scripts and
Storage
security tenancy metadata
Tags in Amazon EC2
• Assign a
name and
other tags to
your AWS
AWS Cloud
resources.
• Manage,
search, and
CLI command:
filter Stop EC2 instances
resources. with “Dev2” tag
value Owner: Owner: Owner:
• More tags
Dev1 Dev2 Dev3
are better
than fewer.
• Tags are
case-
sensitive.
Amazon Machine Image (AMI)
AMI
components:
• Template Amazon EC2 service
for instance
volumes
• Launch EC2 instance
permissions Create Deploy
• Block
device
mapping EC2 instance AMI EC2 instance
Benefits:
• Repeatable EC2 instance
• Reusable
• Recoverable
Where to get an AMI
Choose from the
following:
EC2 Image
Builder
Use Search the AWS Create your
prebuilt Marketplace for a own AMIs
AMIs catalog with manually,
offered by thousands of or use EC2
AWS. solutions. Image Builder
Understanding instance type names
Instance
generation Instance size
c6g.xlarge
Instance Additional
family properties
EC2 instance families
General Storage Compute
purpose Memory optimized optimized optimized Accelerated compute
I3/ P4d
Mac T3 M5 M5zn R5 X1 z1d U* C5 G4 F1 Inf1
I3en n
D3/
T3a M5a R5a X1e D3e C5a G4a
n d
T4g M6g R6g H1 C6g
4:1 Memory 8:1 Memory 2:1 Memory
(GiB) to vCPU (GiB) to (GiB) to
ratio vCPU ratio vCPU ratio
Benefits of newer generation instance types
SQL Server Testing with HammerDB:
Average Cost Per 1 Billion Transactions Per Month
$60.00 $56.61
$50.00
Increase $43.08
compute
$40.00
capabilities
and reduce
processing $30.00
costs.
$20.00
$10.00
$0.00
m4.xlarge m5.xlarge
AWS Compute Optimizer
Resource
✓ configuratio
✓ n
✓
✓
Usage data Receive cross-
AWS Reconfigure
Opt in your Compute service
resources
accounts to get Optimizer Recommendatio integration
based on
started ns recommendatio
recommendation
ns exported to
Resource analysis s
Amazon S3
ML, based on CloudWatch
data
Apply insights from millions of workloads.
Save time by comparing and selecting resources.
Amazon EC2 key pairs
Public
keys
Private
key
Tenancy
Shared tenancy Dedicated Dedicated Host
Share your Instance
Isolate your Control your
hardware. hardware. hardware.
$ D D $$ $$ $$ $$
D = potential compute available
$ = purchased compute
Placement groups and use cases
With placement groups, choose how close or far your instances are from each
other.
Requirements Solution Example use case
Provide low network Cluster High performance computing
latency and high network EC2 instances (HPC)
throughput. near each other.
Critical instances must
Spread
across network Medical health record system
be fault-tolerant. segments and
racks.
Avoid correlated
Partition Large distributed and
replicated workloads like
in logical groups
hardware failures. on separate Kafka, Hadoop, and
hardware. Cassandra
User data
Amazon EC2 service
#!/bin/bash
• Runs scripts
as root after yum update –y
the yum install -y httpd
instance service httpd start
Linux Linux EC2
launches chkconfig httpd on
AMI instance
• Can be
used to User
perform data
common
automated <powershell>
configuratio
Install-WindowsFeature –Name Web-Server
n tasks
</powershell>
Window Windows
s AMI EC2 instance
Instance metadata
Your AMI User data Running EC2
instance
#!/bin/bash
yum update –y
hostname = $(curl -s http://169.254.169.254/latest/meta-data/public-hostname)
Data about the EC2 Metadata Value
instance can be instance-id i-1234567890abcdef0
used for mac 00-1B-63-84-45-E6
automation. public-hostname ec2-203-0-113-25.compute-1.amazonaws.com
public-ipv4 203.0.113.25
Note: You can only get
metadata with a request local-hostname ip-10-251-50-12.ec2.internal
from your EC2 instance. local-ipv4 10.251.50.12
Storage for EC2 instances
“How do we know which volume type to attach to our EC2
instances?”
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon Elastic Block Store (Amazon EBS)
• Create block-level
storage with
automatic volume
replication in your Primary
Availability Zone.
• Attach one or Instance A
more EBS
volumes to a
Secondar
single EC2
y
instance.
• Move EBS Volumes
volumes between
Host Amazon
EC2 instances as
EBS
needed.
Amazon EBS volume types
• Solid state
drive (SSD)
is for high-
performance
and general-
purpose
workloads. EBS SSD- gp2 gp3 io1 io2
• Hard disk backed volumes
drive (HDD)
is for big or
infrequently
accessed
data.
• io2 includes
options for
Block EBS HDD- st1 sc1
Express. backed volumes
Amazon EBS volume characteristics (1 of 2)
General Purpose SSD Provisioned IOPS SSD
Volume type gp2 gp3 io1 io2 io2 Block Express
Volume that balances Highest-performance SSD Next generation of Amazon
price and performance for volume for mission-critical EBS storage service
Description a wide variety of low-latency or high- architecture built for the
workloads throughput workloads cloud
Size 1 GiB to 16 TiB 4 GiB to 16 TiB 4 GiB to 64 TiB
16,000 16,000
Max IOPS (burst) (no burst)
64,000 256,000
Max throughput
250 MiB/s 1,000 MiB/s 1,000 MiB/s 4,000 MiB/s
per volume
Amazon EBS volume characteristics (2 of 2)
Throughput Optimized HDD Cold HDD
Volume type st1 sc1
Low-cost HDD volume designed Lowest-cost HDD volume
Description for frequently accessed, designed for less frequently
throughput-intensive workloads accessed workloads
Size 125 GiB to 16 TiB 125 GiB to 16 TiB
Max IOPS 500 250
Max throughput
500 MiB/s 250 MiB/s
per volume
Instance store volumes
• Local to EC2 instance EC2 instance EC2 instance
instance running stopping stopped
• Non-
persistent
• Doesn’t
support
snapshots
• Available in
HDD, SSD,
and non-
volatile
memory
express SSD Instance Instance All data on
(NVMe SSD) store with store with the instance
varieties data data store is lost
Amazon EC2 pricing options
“How can we optimize cost for compute resources?”
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2 purchase options
On-Demand Savings Plans Spot Instances
Pay for compute 1-year or 3-year Spare Amazon EC2
capacity per second or commitment with varied capacity at savings of up
hour with no long-term flexibility based on type to 90% off On-Demand
commitments of Savings Plan costs
Spiky workloads or Committed Fault-tolerant,
temporary needs flexible access to flexible, stateless
compute workloads
Savings Plan types
Compute Savings Plans Flexible across:
Greatest flexibility, up to • Instance family • Tenancy
66% off On-Demand rates, • Size • Availability
and applies to AWS
Fargate and AWS Lambda • OS Zone
usage. • Region
EC2 Instance Savings
Plans Flexible across:
Provide the lowest prices, • Availability Zone
up to 72% off On-Demand
• Size
rates on the selected
instance family in a specific • OS
AWS Region. • Tenancy
EC2 Spot Instances
Use the same Get the Plan for Diversify
infrastructure best value interruptions your fleet
Run on the same Decide what you Prepare for capacity Choose different
hardware as can pay for compute changes in your instance types, size,
On-Demand and and save up to 90% Availability Zones. and Availability
Savings Plans. from the On- Zone.
Demand price.
Use cases for Spot Instances
Image and Web Big data and
media rendering services analytics
Manage rendering Launch Spot Accelerate and
projects cost effectively to Instances to scale scale time-critical,
web services and hyper-scale
meet deadlines. applications at a workloads.
lower cost.
Combining purchase options
$35
$30 Spiky, unpredictable Amazon
On-Demand
EC2 usage that is not suitable
List price
for Spot
$25
Cost/hr.
Workloads that are fault-
Spot Instances
$20 tolerant, flexible, and
Discounts up to 90%
stateless
$15 Steady usage where the
Compute Savings Plans
flexibility to change
Discounts up to 66%
$10 is important
Steady usage unlikely to EC2 Instance
$5 change during the Savings Plans
commitment Discounts up to 72%
$0
Time
AWS Lambda
“Where can we start with serverless compute options?”
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Serverless computing
Computing with virtual Serverless computing
servers
• Highly
available
• Fully
managed
by AWS
Server Code Code
s
AWS Lambda
• Serverless Invoke
compute
• Supports
Node.js, Java,
Python, C#,
Go,
PowerShell, Event Lambda
Ruby, and source
Services
more Optional response
• Runs for up
to 15
minutes
• Supports up
to 10 GB
memory Function code
Event source examples
Amazon AWS Amazon Simple Email Amazon S3 AWS Amazon
DynamoDB CodeCommit Service (Amazon SES) IoT services Alexa
Amazon AWS Amazon Simple Amazon Amazon API
CloudWatch CloudFormation Queue Service Cognito Gateway
(Amazon SQS)
AWS Amazon Amazon Simple Application
CloudTrail EventBridge Notification Service Load
(Amazon SNS) Balancer
AWS Step Functions Amazon Kinesis
Use cases
Web applications Backends Data Chatbots Amazon Alexa IT automation
processing
Review
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Present Consider how you would answer the
following:
solutions
• What AWS compute services are
there?
• What should the team consider when
deploying new and existing servers to
Amazon EC2?
• How do we know which volume type
to attach to our EC2 instances?
Compute • How can we optimize cost for compute
Operations resources?
Manager
• Where can we start with serverless
compute options?
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Module review
In this module you learned about:
Compute services Amazon EC2 pricing options
EC2 instances AWS Lambda
Instance storage
Next, you will review:
Capstone check-in Lab introduction
Knowledge check
Capstone architecture
Region
VPC
Availability Zone
Public subnet App subnet Database
subnet
NAT gateway EFS mount
App Aurora replica
target
servers
Application
Load Auto
Balancer Scaling
group Amazon EFS
Internet Public subnet Database
gateway subnet
EFS mount
target Aurora
primary DB
NAT App servers App subnet instance
gateway
Availability Zone
Capstone architecture check-in
Region
VPC
Availability Zone
Public subnet App subnet Database
subnet
NAT gateway
App
servers
Internet Public subnet Database
gateway subnet
NAT App servers App subnet
gateway
Availability Zone
Knowledge check
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Knowledge check question 1
Which of the following are true of AMIs? (Select TWO.)
A AMIs can specify the subnets for launch.
AMIs can include block device mapping that specifies the volumes to attach to the
B
Amazon EC2 instance when it is launched.
C AMIs can only be obtained from the AWS Marketplace.
D You can launch multiple instances from a single AMI.
E AMIs can only be used by users within a single account.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Knowledge check question 1 and answer
Which of the following are true of AMIs? (Select TWO.)
A AMIs can specify the subnets for launch.
B AMIs can include block device mapping that specifies the volumes to attach to the
correct Amazon EC2 instance when it is launched.
C AMIs can only be obtained from the AWS Marketplace.
D
correct You can launch multiple instances from a single AMI.
E AMIs can only be used by users within a single account.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Knowledge check question 2
In the instance type name m6g.2xlarge, which aspect of the name indicates the instance
family and helps to determine its best use case?
A m
B g
C 2xlarge
D 6
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Knowledge check question 2 and answer
In the instance type name m6g.2xlarge, which aspect of the name indicates the instance
family and helps to determine its best use case?
A
correct m
B g
C 2xlarge
D 6
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Knowledge check question 3
Which of the following are true statements regarding Lambda? (Select TWO.)
A Functions currently only support Python.
B You are responsible for updating and patching Lambda servers.
C Functions can be allocated up to 10 GB of memory.
D Functions can run for a maximum of 15 minutes.
E Functions require a security group.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Knowledge check question 3 and answer
Which of the following are true statements regarding Lambda? (Select TWO.)
A Functions currently only support Python.
B You are responsible for updating and patching Lambda servers.
C
correct Functions can be allocated up to 10 GB of memory.
D
correct Functions can run for a maximum of 15 minutes.
E Functions require a security group.
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Lab 2:
Build your Amazon VPC infrastructure
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserve
Lab 2 diagram
Region
VPC (10.0.0.0/16)
Internet
gateway
Public subnet (10.0.0.0/24) Public Route Table
Destination Target
Public security
group 10.0.0.0/16 local
0.0.0.0/0 igw-021345abcdef67
NAT gateway EC2 instance
Private subnet (10.0.2.0/23) Private Route
Destination Table Target
Private security
group 10.0.0.0/16 local
0.0.0.0/0 nat-abcdef01234567
EC2 instance
Availability Zone
Lab tasks
Connect to the Amazon EC2
Task 1: Create an Amazon VPC in a Region. Task 8:
instance in the public subnet.
Create a NAT gateway and
Task 2: Create public and private subnets. Task 9: configure routing in the private
subnet.
Task 3: Create an internet gateway. Create a security group for private
Task 10:
resources.
Route internet traffic in the public
Task 4: Launch an Amazon EC2 instance
subnet to the internet gateway. Task 11:
into a private subnet.
Task 5: Create a public security group. Connect to the Amazon EC2
Task 12:
instance in the private subnet.
Launch an Amazon EC2 instance
Task 6:
into a public subnet. Optional Test connectivity to the private
Task 1: instance from the public instance.
Connect to a public instance via
Task 7: Optional
HTTP. Retrieve instance metadata.
Task 2:
End of Module 4
© 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.