2.1 Compute
2.1 Compute
Module 6: Compute
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module overview
Topics Activities
• Compute services overview • Amazon EC2 versus Managed Service
• Amazon EC2 • Hands-on with AWS Lambda
• Amazon EC2 cost optimization • Hands-on with AWS Elastic Beanstalk
• Container services
• Introduction to AWS Lambda Demo
• Introduction to AWS Elastic Beanstalk • Recorded demonstration of Amazon EC2
Lab
• Introduction to Amazon EC2
Knowledge
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
check 2
Module objectives
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 3
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS compute services
Amazon Web Services (AWS) offers many compute services. This module will discuss the
highlighted services.
Amazon EC2 Amazon EC2 Amazon Elastic Amazon Elastic VMware Cloud
Auto Scaling Container Registry Container Service on AWS
(Amazon ECR) (Amazon ECS)
AWS Elastic AWS Lambda Amazon Elastic Amazon Lightsail AWS Batch
Beanstalk Kubernetes Service
(Amazon EKS)
• The optimal compute service or services that you use will depend on
your use case
• 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
• A good starting place—Understand the available compute options
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 7
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Elastic Compute Cloud (Amazon
EC2)
Example uses of
Amazon EC2
instances
✔ Application server
✔ Web server
✔ Database server
✔ Game server
✔ Mail server
✔ Media server
✔ Catalog server Amazon EC2
Photo by Taylor ✔ File server
instances
Vick on Unsplash
✔ Computing server
On-premises
✔ Proxy server
servers
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 11
1. Select an AMI
1. AMI
• Amazon Machine Image (AMI)
2. Instance Type
• Is a template that is used to create an EC2 instance (which is a virtual
3. Network settings machine, or VM, that runs in the AWS Cloud)
4. IAM role
• Contains a Windows or Linux operating system
5. User data
• Often also has some software pre-installed
6. Storage options
7. Tags • AMI choices:
8. Security group • Quick Start – Linux and Windows AMIs that are provided by AWS
9. Key pair • My AMIs – Any AMIs that you created
• AWS Marketplace – Pre-configured templates from third parties
• Community AMIs – AMIs shared by others; use at your own risk
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 12
Creating a new AMI: Example
AWS Cloud
AMI
details Region A
Connect to the instance
and manually modify it
or run a script that
Quick Start
modifies the instance
or other
Launch (for example, upgrade Capture
existing AMI
Starter an installed software) as
AMI instance a new AMI
1 2 3
Unmodified Modified New
Instance Instance AMI
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 13
2. Select an instance type
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 14
EC2 instance type naming and sizes
Instance type Example instance
details
sizes
Instance
vCPU Memory (GB) Storage
Name
Instance type naming t3.nano 2 0.5 EBS-Only
t3.large 2 8 EBS-Only
t3.xlarge 4 16 EBS-Only
t3.2xlarge 8 32 EBS-Only
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 15
Select instance type: Based on use
case
Instance type
details
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 16
Instance types: Networking features
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 17
3. Specify network settings
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 18
4. Attach IAM role (optional)
Choices made by using • Will software on the EC2 instance need to interact with other
the AWS services?
Launch Instance Wizard: • If yes, attach an appropriate IAM Role.
1. AMI
• An AWS Identity and Access Management (IAM) role that is
2. Instance Type
attached to an EC2 instance is kept in an instance profile.
3. Network settings • You are not restricted to attaching a role only at instance
4. IAM role launch.
5. User data • You can also attach a role to an instance that already
6. Storage options exists.
7. Tags
Example Application on
8. Security group : attached to instance can
9. Key pair access
Role that grants Amazon
S3 bucket
Simple Storage Service Instance
with objects
(Amazon S3) bucket
access permissions
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 19
5. User data script (optional)
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 20
6. Specify storage
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 21
Amazon EC2 storage options
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 22
Example storage options
Host computer
• Instance 1 characteristics Amazon Elastic
Block Store
– (Amazon EBS) Instance
• It has an Amazon EBS root Store
volume type for the operating Attached as Attached as
system. Root Storage
• What will happen if the instance 20-GB volume volume volume Ephemeral
Instance 1
is stopped and then started volume 1
again? Attached as
Storage
volume Attached as
500-GB volume Root
• Instance 2 characteristics
volume Ephemeral
– Instance 2
volume 2
• It has an Instance Store root
volume type for the operating
system.
• What will happen if the instance
stops (because of user error or
a system malfunction)?
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 23
7. Add tags
Choices made by using • A tag is a label that you can assign to an AWS
the resource.
Launch Instance Wizard:
• Consists of a key and an optional value.
1. AMI • Tagging is how you can attach metadata to an
2. Instance Type
EC2 instance.
3. Network settings
4. IAM role • Potential benefits of tagging—Filtering,
5. User data automation, cost allocation, and access control.
6. Storage options
7. Tags
8. Security group
Example:
9. Key pair
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 24
8. Security group settings
Example rule:
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 25
9. Identify or create the key pair
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 27
Another option: Launch an EC2 instance
with the AWS Command Line Interface
• EC2 instances can also be created
programmatically.
AWS Command Line
Interface (AWS CLI)
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 28
Amazon EC2 instance lifecycle
Launch Start
pending
AMI
Reboot Stop
rebooting running stopping stopped
Stop-Hibern
ate
Terminate
shutting-dow
n
Terminate
terminated
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 29
Instance hibernation option
• Benefits
• It saves the contents from the instance memory (RAM).
• On instance restart, RAM contents are reloaded, previously running processes are resumed.
• You can save on cost in a hibernated state versus a running state (costs are similar to a
stopped instance).
• Prerequisites
• Only certain Linux AMIs (such as Amazon Linux 2) and only certain instance families support
it.
• Instance must have an encrypted Amazon EBS root volume and a maximum of150 GB RAM.
• Hibernation
© 2019 Amazon Web Services, Inc. or itsmust
Affiliates. Allbe
rightsenabled
reserved. at instance launch. 30
Consider using an Elastic IP address
Elastic IP
Address
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 31
EC2 instance metadata
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 32
Amazon CloudWatch for monitoring
• Basic monitoring
• Default, no additional cost
• Metric data sent to CloudWatch every 5 minutes
• Detailed monitoring
• Fixed monthly rate for seven pre-selected metrics
• Metric data delivered every 1 minute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 33
• Amazon EC2 enables you to run Windows and
Section 2 key Linux virtual machines in the cloud.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon EC2 pricing models
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 37
Amazon EC2 pricing models: Use
cases
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 38
The four pillars of cost optimization
Cost Optimization
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 39
Pillar 1: Right size
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 40
Pillar 2: Increase elasticity
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 41
Pillar 3: Optimal pricing model
•Recommendations –
• Define and enforce cost allocation tagging.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 44
• Amazon EC2 pricing models include
Section 3 key On-Demand Instances, Reserved Instances,
Spot Instances, Dedicated Instances, and
takeaways Dedicated Hosts.
45 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 46
AWS Lambda: Run code without
servers
AWS Lambda is a serverless compute
service.
Upload your
code
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 47
Benefits of Lambda
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 48
AWS Lambda event sources
Event sources Configure other AWS services as event sources to
invoke your function as shown here.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 49
AWS Lambda function configuration
Lambda function configuration
Function code
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 50
Schedule-based Lambda function example:
Start and stop EC2 instances
Stop
1 2 3
Start
4 5 6
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 51
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Event-based Lambda function example:
Create thumbnail images
AWS Cloud
1
2 3
Use
r
Sour Lambda 4
ce
buck Execution
et 5
role
Acce
ss
polic
Targ
y
et Lamb
buck da
et functio
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 52
n
AWS Lambda quotas
Additional limits also exist. Details are in the AWS Lambda quotas documentation.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 53
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Serverless computing enables you to build
Section 5 key and run applications and services without
provisioning or managing servers.
takeaways
• AWS Lambda is a serverless compute
service that provides built-in fault tolerance
and automatic scaling.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Elastic Beanstalk
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 57
Benefits of Elastic Beanstalk
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 58
Module 6: Compute
Module wrap-up
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module summary
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 60
Complete the knowledge check
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 61
Sample exam question
A. AWS CloudFormation
B. AWS SQS
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 62
Additional resources
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 63
Thank you
© 2019 Amazon Web Services, Inc. or its affiliates. All rights reserved. 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.