module 6
module 6
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 check 2
reserved.
Module objectives
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 Photo by panumas nikhomkhai from Pexels
9
reserved.
Amazon EC2 overview
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
t3.large 2 8 EBS-Only
t3.xlarge 4 16 EBS-Only
t3.2xlarge 8 32 EBS-Only
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
attached to an EC2 instance is kept in an instance profile.
2. Instance Type
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
19
reserved.
5. User data script (optional)
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
6. Storage options control.
7. Tags
8. Security group
9. Key pair Example:
Example rule:
Launch Start
pending
AMI
Reboot Stop
rebooting running stopping stopped
Stop-
Hibernate
Terminate
shutting-
down
Terminate
terminated
• 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.
reserved.• Hibernation must be enabled at instance launch.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
30
Consider using an Elastic IP address
Elastic IP
Address
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
31
reserved.
EC2 instance metadata
• 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
35 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lab 3:
Introduction to
Amazon EC2
36 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lab 3 scenario
In this lab, you will launch and configure your first virtual machine that
runs on Amazon EC2.
AWS Cloud
Region
Availability Zone 1
Lab VPC
Public subnet
Web server
instance
Amazon Elastic
Block Store
(Amazon EBS)
~ 35 minutes
42 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity: Gather information
Amazon EC2 Amazon RDS
AWS Cloud
Availability Zone 1 Availability Zone 2
MS SQL Server MS SQL Server
primary DB instance secondary
Always-on DB instance
mirroring
1. Between Amazon EC2 or Amazon RDS, which provides a managed service? What does
managed service mean?
• ANSWER: Amazon RDS provides a managed service. Amazon RDS handles provisioning, installation
and patching, automated backups, restoring snapshots from points in time, high availability, and
monitoring.
2. Name at least one advantage of deploying Microsoft SQL Server on Amazon EC2 instead of
Amazon RDS.
• ANSWER: Amazon EC2 offers complete control over every configuration, the OS, and the software
stack.
3. What advantage does the Quick Start provide over a manual installation on Amazon EC2?
• ANSWER: The Quick Start is a reference architecture with proven best practices built into the design.
4. Which deployment option offers the best approach for all use cases?
• ANSWER: Neither. The correct deployment option depends on your specific needs.
5. Which approach costs more: using Amazon EC2 or using Amazon RDS?
• ANSWER: It depends. Managing the database deployment on Amazon EC2 requires more customer
oversight
© 2019 Amazon and
Web Services, Inc. time.AllIfrights
or its Affiliates. time is your priority, then Amazon RDS might be less expensive. If you have in- 44
reserved.
house expertise, Amazon EC2 might be more cost-effective.
Module 6: Compute
✔Examples:
• Use On-Demand Instance and Spot Instances for
variable workloads
• Recommendations –
• Define and enforce cost allocation tagging.
55 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
run.
Hypervisor
Part of
Host operating system AWS Global
Infrastructure
Physical server
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
59
reserved.
Amazon Elastic Container Service
(Amazon ECS)
• Amazon Elastic Container Service (Amazon ECS) –
• A highly scalable, fast, container management service
• Integrated with features that are familiar to Amazon EC2 service users –
• Elastic Load Balancing
• Amazon EC2 security groups
• Amazon EBS volumes
• IAM roles
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
60
reserved.
Amazon ECS orchestrates containers
EC2 instance
Requests to run containers
x3 x2
Container A
EC2 instance
Container B
Amazon Elastic Container
Service (Amazon ECS)
• 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
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
62
reserved.
What is Kubernetes?
Docker support
Team collaboration
Amazon Elastic
Container Registry Access control
Third-party integrations
Image Registry
66 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
AWS HTTP
servi endpoint Your code Pay only for the
ces Mobile s
apps
runs only when compute time
Run your code on a schedule
it is that
or in response to events
triggered you use
Function code
Stop
IAM role
Time-based
1 CloudWatch 2 Lambda function 3 EC2 instances
event triggered stopped
Start instances
example
Start
IAM role
Time-based
4 5 Lambda function 6 EC2 instances
CloudWatch
triggered started
event
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
72
reserved.
© 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
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights
et functio
73
reserved.
n
AWS Lambda quotas
Additional limits also exist. Details are in the AWS Lambda quotas documentation.
76 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity debrief:
key takeaways
82 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity debrief:
Key takeaways
84 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
Module wrap-up
A. AWS CloudFormation
B. AWS SQS
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 88
Additional resources
© 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: aws-course-
feedback@amazon.com. For all other questions, contact us at: https://aws.amazon.com/contact-us/aws-training/. All trademarks are the property of their owners.