masterclass webinar: amazon ec2
DESCRIPTION
Developing applications on Amazon Web Services (AWS) or moving your business into the cloud is more straightforward than you think. Whether you are a developer eager to learn new skills, a solutions architect who wants to solve existing technology problems, the IT professional who wants access to cost-effective, on-demand computing resources, this workshop is for you. These slides feature some of the most popular Amazon Web Services: Amazon Elastic Compute Service (EC2), Amazon Simple Storage Service (S3), Amazon CloudFront, Amazon Elastic Block Storage (EBS) and Amazon Relational Database Service (RDS). Amazon EC2 YouTube Recording: http://youtu.be/TORzO9Oc9oU Amazon EC2 Demo: http://youtu.be/kMExnVKhmYcTRANSCRIPT
![Page 1: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/1.jpg)
Masterclass
Elastic Compute Cloud
Ryan Shuttleworth – Technical Evangelist @ryanAWS
![Page 2: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/2.jpg)
A technical deep dive beyond the basics Help educate you on how to get the best from AWS technologies
Show you how things work and how to get things done Broaden your knowledge in ~45 mins
Masterclass
![Page 3: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/3.jpg)
On-demand compute to run application workloads Easy come easy go – disposable resource
We provide the infrastructure, you decide what you run
Amazon EC2
![Page 4: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/4.jpg)
What is EC2?
Elastic capacity Flexible
Complete control
Reliable
Inexpensive
Secure
![Page 5: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/5.jpg)
Securely segregated
Shared environment
Elastic capacity
Physical Interfaces
Customer 1
Hypervisor
Customer 2 Customer n …
… Virtual Interfaces
Firewall
Customer 1
Security
Groups
Customer 2
Security
Groups
Customer n
Security
Groups
![Page 6: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/6.jpg)
Securely segregated
Shared environment
Elastic capacity
Physical Interfaces
Customer 1
Hypervisor
Customer 2 Customer n …
… Virtual Interfaces
Firewall
Customer 1
Security
Groups
Customer 2
Security
Groups
Customer n
Security
Groups
![Page 7: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/7.jpg)
AMI
Amazon Machine Image
![Page 8: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/8.jpg)
AMI
Amazon Machine Image
Instance
Running or Stopped machine
![Page 9: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/9.jpg)
AMI
Amazon Machine Image
Instance
Running or Stopped machine
VPC
EC2
![Page 10: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/10.jpg)
AMI
Amazon Machine Image
Instance
Running or Stopped machine
VPC
EC2
AZ
Region
![Page 11: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/11.jpg)
AMI
Amazon Machine Image
Instance
Running or Stopped machine
VPC
EC2
AZ Availability Zone
VPC
EC2
Region
![Page 12: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/12.jpg)
AMI
Amazon Machine Image
Instance
Running or Stopped machine
VPC
EC2
AZ Availability Zone
EBS EBS EBS
VPC
EC2
EBS EBS EBS
Region
![Page 13: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/13.jpg)
AMI
Amazon Machine Image
Instance
Running or Stopped machine
VPC
EC2
AZ Availability Zone
S3
EBS EBS EBS
VPC
EC2
EBS EBS EBS
EBS Snapshots
S3 Buckets
Region
![Page 14: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/14.jpg)
Instance
![Page 15: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/15.jpg)
Instance Unit of scale
Unit of resilience
Unit of control
![Page 16: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/16.jpg)
Instance Unit of scale
Unit of resilience
Unit of control
Your stack
![Page 17: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/17.jpg)
Instance
Instance
Instance
Instance
Unit of scale
Unit of resilience
Unit of control
Scal
e o
ut
![Page 18: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/18.jpg)
Instance
Instance
Instance
Instance
Unit of scale
Unit of resilience
Unit of control
![Page 19: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/19.jpg)
Instance
Instance
Instance
Instance
Unit of scale
Unit of resilience
Unit of control
![Page 20: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/20.jpg)
Instance
Instance
Instance
Unit of scale
Unit of resilience
Unit of control
![Page 21: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/21.jpg)
Instance
Instance
Instance
Unit of scale
Unit of resilience
Unit of control
Instance
![Page 22: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/22.jpg)
Instance types Choose the right unit for your workload
![Page 23: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/23.jpg)
256
128
64
32
16
8
4
2
1
1 2 4 8 16 32 64 128 256
High I/O 4XL 60.5 GB 35 EC2 Compute Units 16 virtual cores 2*1024 GB SSD-based local instance storage
EC2 Compute Units
Me
mo
ry (
GB
)
Small 1.7 GB, 1 EC2 Compute Unit 1 virtual core
Micro 613 MB Up to 2 ECUs (for short bursts)
Large 7.5 GB 4 EC2 Compute Units 2 virtual cores
Hi-Mem XL 17.1 GB 6.5 EC2 Compute Units 2 virtual cores
Hi-Mem 2XL 34.2 GB 13 EC2 Compute Units 4 virtual cores
Hi-Mem 4XL 68.4 GB 26 EC2 Compute Units 8 virtual cores
High-CPU Med 1.7 GB 5 EC2 Compute Units 2 virtual cores
High-CPU XL 7 GB 20 EC2 Compute Units 8 virtual cores
Medium 3.7 GB, 2 EC2 Compute Units 1 virtual core
M3 XL 15 GB 13 EC2 Compute Units 4 virtual cores EBS storage only
M3 2XL 30 GB 26 EC2 Compute Units 8 virtual cores EBS storage only
Extra Large 15 GB 8 EC2 Compute Units 4 virtual cores
10 GB Inter-Instance
Network
Cluster GPU 4XL 22 GB 33.5 EC2 Compute Units, 2 x NVIDIA Tesla “Fermi” M2050 GPUs
Cluster Compute 4XL 23 GB 33.5 EC2 Compute Units
Cluster Compute 8XL 60.5 GB 88 EC2 Compute Units
High Storage 8XL 117 GB 35 EC2 Compute Units, 24 * 2 TB ephemeral drives 10 GB Ethernet
Hi-Mem Cluster Compute 8XL 244 GB 88 EC2 Compute Units 16 virtual cores 240 GB SSD
![Page 24: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/24.jpg)
Start small Easy to up-size
![Page 25: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/25.jpg)
AMIs
Your machine images
AMIs you have created from
EC2 instances
Can be kept private or shared with other accounts
Amazon maintained
Set of Linux and Windows
images
Kept up to date by Amazon in each region
Community maintained
Images published by other
AWS users
Managed and maintained by Marketplace partners
![Page 26: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/26.jpg)
http://aws.amazon.com/amazon-linux-ami/
![Page 27: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/27.jpg)
Windows Linux Enterprise Linux
Small instance from $0.060 per hour
Small instance from $0.115 per hour
AMIs
Small instance from $0.120 per hour
Small instance from $0.090 per hour
![Page 28: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/28.jpg)
Unix/Linux instances start at $0.02/hour
Pay as you go for compute power
Low cost and flexibility
Pay only for what you use, no up-front commitments or long-term contracts
Use Cases:
Applications with short term, spiky, or
unpredictable workloads;
Application development or testing
On-demand instances
Instance types
![Page 29: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/29.jpg)
Unix/Linux instances start at $0.02/hour
Pay as you go for compute power
Low cost and flexibility
Pay only for what you use, no up-front commitments or long-term contracts
Use Cases:
Applications with short term, spiky, or
unpredictable workloads;
Application development or testing
On-demand instances
1- or 3-year terms
Pay low up-front fee, receive significant hourly discount
Low Cost / Predictability
Helps ensure compute capacity is available
when needed
Use Cases:
Applications with steady state or predictable usage
Applications that require reserved capacity,
including disaster recovery
Reserved instances
Instance types
![Page 30: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/30.jpg)
Unix/Linux instances start at $0.02/hour
Pay as you go for compute power
Low cost and flexibility
Pay only for what you use, no up-front commitments or long-term contracts
Use Cases:
Applications with short term, spiky, or
unpredictable workloads;
Application development or testing
On-demand instances
1- or 3-year terms
Pay low up-front fee, receive significant hourly discount
Low Cost / Predictability
Helps ensure compute capacity is available
when needed
Use Cases:
Applications with steady state or predictable usage
Applications that require reserved capacity,
including disaster recovery
Reserved instances
> 80% utilization Lower costs up to 58%
Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline
Heavy utilization RI Instance types
![Page 31: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/31.jpg)
Unix/Linux instances start at $0.02/hour
Pay as you go for compute power
Low cost and flexibility
Pay only for what you use, no up-front commitments or long-term contracts
Use Cases:
Applications with short term, spiky, or
unpredictable workloads;
Application development or testing
On-demand instances
1- or 3-year terms
Pay low up-front fee, receive significant hourly discount
Low Cost / Predictability
Helps ensure compute capacity is available
when needed
Use Cases:
Applications with steady state or predictable usage
Applications that require reserved capacity,
including disaster recovery
Reserved instances
> 80% utilization Lower costs up to 58%
Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline
Heavy utilization RI
41-79% utilization Lower costs up to 49%
Use Cases: Web applications, many heavy processing tasks, running much of the time
Medium utilization RI
Instance types
![Page 32: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/32.jpg)
Unix/Linux instances start at $0.02/hour
Pay as you go for compute power
Low cost and flexibility
Pay only for what you use, no up-front commitments or long-term contracts
Use Cases:
Applications with short term, spiky, or
unpredictable workloads;
Application development or testing
On-demand instances
1- or 3-year terms
Pay low up-front fee, receive significant hourly discount
Low Cost / Predictability
Helps ensure compute capacity is available
when needed
Use Cases:
Applications with steady state or predictable usage
Applications that require reserved capacity,
including disaster recovery
Reserved instances
> 80% utilization Lower costs up to 58%
Use Cases: Databases, Large Scale HPC, Always-on infrastructure, Baseline
Heavy utilization RI
41-79% utilization Lower costs up to 49%
Use Cases: Web applications, many heavy processing tasks, running much of the time
Medium utilization RI
15-40% utilization Lower costs up to 34%
Use Cases: Disaster Recovery, Weekly / Monthly reporting, Elastic Map Reduce
Light utilization RI
Instance types
![Page 33: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/33.jpg)
Unix/Linux instances start at $0.02/hour
Pay as you go for compute power
Low cost and flexibility
Pay only for what you use, no up-front commitments or long-term contracts
Use Cases:
Applications with short term, spiky, or
unpredictable workloads;
Application development or testing
On-demand instances
1- or 3-year terms
Pay low up-front fee, receive significant hourly discount
Low Cost / Predictability
Helps ensure compute capacity is available
when needed
Use Cases:
Applications with steady state or predictable usage
Applications that require reserved capacity,
including disaster recovery
Reserved instances
Bid on unused EC2 capacity
Spot Price based on supply/demand, determined automatically
Cost / Large Scale, dynamic workload handling
Use Cases:
Applications with flexible start and end times
Applications only feasible at very low compute prices
Spot instances
Instance types
![Page 34: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/34.jpg)
Launch an instance Commands, keypairs & security groups
![Page 35: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/35.jpg)
![Page 36: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/36.jpg)
Region
Instance size
AMI
Key pair
Security group
![Page 37: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/37.jpg)
key pairs secure access
![Page 38: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/38.jpg)
Public Key
Inserted by Amazon into each EC2 instance that
you launch
Private Key
Downloaded and stored by you
EC2 Instance
Comms secured with private key
![Page 39: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/39.jpg)
x.509 Keypairs Credentials
Used to authenticate when accessing and
instance
Used to authenticate against some APIs
Keypairs & Secrets
Access key and secret key used to authenticate
against APIs
![Page 40: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/40.jpg)
security groups instance firewalling
![Page 41: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/41.jpg)
Security Group
instance
Port 80 (HTTP)
Port 22 (SSH)
Name Description Protocol Port range IP Address, range, or another security group
![Page 42: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/42.jpg)
PS C:> New-EC2Instances
-ImageId ami-269dbb63
-KeyName mykey
-SecurityGroupId sg-9cf9e5d9
-InstanceType t1.micro
![Page 43: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/43.jpg)
ec2-run-instances ami-54cf5c3d
--instance-count 2
--group webservers
--key mykey
--instance-type m1.small
$>
![Page 44: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/44.jpg)
>>> import boto.ec2
>>> conn = boto.ec2.connect_to_region("us-east-1")
>>> conn.run_instances(
'ami-54cf5c3d',
key_name='mykey',
instance_type='m1.small',
security_groups=['webservers'])
![Page 45: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/45.jpg)
Wait a minute I want to use those tools too…
![Page 46: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/46.jpg)
IAM Roles and EC2 tools
1. Start an EC2 Linux instance
2. Assign an IAM role at launch time:
3. Sets up all the tools you need & manages API access credentials
1. Up and running with CLI tools in a couple
of minutes – just SSH on and use
2. Terminate/stop instance when you are done
{
"Statement": [
{
"Effect": "Allow",
"NotAction": "iam:*",
"Resource": "*"
}
]
}
![Page 47: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/47.jpg)
Now you have tools Try this…
![Page 48: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/48.jpg)
ec2-run-instances ami-54cf5c3d
--instance-count 1
$>
![Page 49: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/49.jpg)
ec2-run-instances ami-54cf5c3d
--instance-count 1
--group webservers
--key mykey
--instance-type m1.small
$>
What about all this?
![Page 50: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/50.jpg)
ec2-run-instances ami-54cf5c3d
--instance-count 1
--group Default
--key NONE
--instance-type default(m1.small)
$>
Defaults
![Page 51: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/51.jpg)
ec2-run-instances ami-54cf5c3d
--instance-count 1
--group Default
--key NONE
--instance-type default(m1.small)
$>
![Page 52: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/52.jpg)
Instances don’t need keypairs But how do you configure it if you can’t log
onto it?
![Page 53: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/53.jpg)
Bake an AMI
Start an instance
Configure the instance
Create an AMI from your instance
Start new ones from the AMI
Bootstrapping
![Page 54: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/54.jpg)
Bake an AMI Configure dynamically
Start an instance
Configure the instance
Create an AMI from your instance
Start new ones from the AMI
Bootstrapping
Launch an instance
Use metadata service and cloud-init to
perform actions on instance when it
launches
vs
![Page 55: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/55.jpg)
Bake an AMI Configure dynamically
Build your base images and setup custom
initialisation scripts
Maintain your ‘golden’ base
Bootstrapping
Use bootstrapping to pass custom
information in and perform post launch
tasks like pulling code from SVN
+
![Page 56: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/56.jpg)
Bake an AMI Configure dynamically
Bootstrapping
Time consuming configuration (startup time)
Static configurations (less change management)
![Page 57: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/57.jpg)
Bake an AMI Configure dynamically
Bootstrapping
Continuous deployment (latest code)
Environment specific (dev-test-prod)
![Page 58: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/58.jpg)
Goal is bring an instance up in a useful state
The balance will vary depending upon your application
![Page 59: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/59.jpg)
Instance
request
User data
![Page 60: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/60.jpg)
Instance
request
User data
Meta-data service
![Page 61: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/61.jpg)
Instance
request
User data
Instance
Meta-data service
![Page 62: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/62.jpg)
#!/bin/sh
yum -y install httpd php mysql php-mysql
chkconfig httpd on
/etc/init.d/httpd start
Shell script in user-data will be executed on launch:
![Page 63: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/63.jpg)
63
Amazon Windows EC2Config Service executes user-
data on launch:
<script>dir > c:\test.log</script>
<powershell>any command that you can run</powershell>
<powershell>
Read-S3Object -BucketName myS3Bucket
-Key myFolder/myFile.zip
-File c:\destinationFile.zip
</powershell>
AWS Powershell Tools (use IAM roles as before…)
![Page 64: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/64.jpg)
Why do this?
Automation Less fingers, less mistakes
Availability Drive higher
availability with self-healing
Security Instances locked down by default
Flexible Shell, Powershell, CloudFormation,
Chef, Puppet, OpsWorks
Scale Manage large scale
deployments and drive autoscaling
Efficiency Audit and manage
your estate with less time & effort
![Page 65: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/65.jpg)
Do
Some does and don’ts
Use IAM roles
Go keyless if you can
Strike a balance between AMI and dynamic
bootstrapping
![Page 66: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/66.jpg)
Do Don’t
Some does and don’ts
Use IAM roles
Go keyless if you can
Strike a balance between AMI and dynamic
bootstrapping
Put your API access keys into code (and then publish
to GIT) or bake into AMIs (and share)
![Page 67: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/67.jpg)
Block storage Understanding instance storage vs EBS
![Page 68: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/68.jpg)
Instance Storage
Local ‘on host’ disk volumes
Data dependent upon instance lifecycle
![Page 69: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/69.jpg)
Elastic Block Storage Instance Storage VS
Local ‘on host’ disk volumes
Data dependent upon instance lifecycle
Network attached optimised block storage
Data independent of instance lifecycle
![Page 70: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/70.jpg)
Instance Storage
Local ‘on host’ disk volumes
Data dependent upon instance lifecycle
Host 1
eph0 eph1 eph2 eph3
Instance Store
Instance A
Instance B
Instance C
Host 2
eph0 eph1 eph2 eph3
Instance Store
Instance D
Instance E
Instance F
![Page 71: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/71.jpg)
Instance Storage
Local ‘on host’ disk volumes
Data dependent upon instance lifecycle
If an instance reboots (intentionally or unintentionally), data in the instance store persists
Data on instance store volumes is lost under the following circumstances:
• Failure of an underlying drive
• Stopping an Amazon EBS-backed instance
• Terminating an instance
![Page 72: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/72.jpg)
Options Differing types of instance storage
![Page 73: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/73.jpg)
Options Differing types of instance storage
![Page 74: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/74.jpg)
Elastic Block Storage
Network attached optimised block storage
Data independent of instance lifecycle
EBS EC2
Workspace
Hypervisor
S3
EBS snapshot
Network
One or more ephemeral (temporary) drives (instance storage)
One or more EBS (persistent) drives
EBS snapshots (backup images)
![Page 75: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/75.jpg)
Elastic Block Storage
Network attached optimised block storage
Data independent of instance lifecycle
EBS EC2
Hypervisor
S3
EBS snapshot
Boot cycle
![Page 76: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/76.jpg)
Elastic Block Storage
Network attached optimised block storage
Data independent of instance lifecycle
EBS EC2
Workspace
Hypervisor
S3
EBS snapshot
Boot cycle
![Page 77: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/77.jpg)
Elastic Block Storage
Network attached optimised block storage
Data independent of instance lifecycle
EBS EC2
Workspace
Hypervisor
S3
EBS snapshot
Boot cycle
![Page 78: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/78.jpg)
Elastic Block Storage
Network attached optimised block storage
Data independent of instance lifecycle
EBS EC2
Workspace
Hypervisor
S3
Boot cycle
Network
![Page 79: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/79.jpg)
EBS Persistence
EBS volume is off-instance storage You pay for the volume usage as long as the data persists 1. By default, EBS volumes that are attached to a running instance
automatically detach from the instance with their data intact when that instance is terminated
2. By default, EBS volumes that are created and attached to an instance at launch are deleted when that instance is terminated. You can modify this behavior by changing the value of the flag DeleteOnTermination to false when you launch the instance.
![Page 80: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/80.jpg)
Elastic Load Balancer Spreading the load and fronting EC2
![Page 81: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/81.jpg)
A regional service Load balance across availability zones
![Page 82: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/82.jpg)
Availability Zone Availability Zone
Region
Availability Zone
Instance Instance Instance Instance Instance Instance
Elastic Load Balancer
![Page 83: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/83.jpg)
Offload
SSL processing on ELB
Remove load from EC2 instances
Spread
Go small and wide
Balance resources across AZs
Health check
Choose the right healthcheck point
Check whole layers
Elastic Load Balancing
![Page 84: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/84.jpg)
1. Persistent HTTP connections – enable them and ELB to Server will be optimized
2. Never address underlying IP – always DNS name • There’s a set behind an ELB and real clients spread
across them • They will change as the ELB scales to keep ahead
of demand
3. If you span ELB across AZs have an instance in all Azs
4. De-register instances from an ELB before terminating
![Page 85: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/85.jpg)
![Page 86: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/86.jpg)
AutoScaling Automate EC2 commissioning and decommisioning
![Page 87: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/87.jpg)
Describes what Auto Scaling will create when adding
Instances
AMI Instance Type
Security Group Instance Key Pair
Only one active launch configuration at a time
Auto Scaling will terminate instances with old launch
configuration first rolling update
Auto Scaling managed grouping of EC2 instances
Automatic health check to
maintain pool size
Automatically scale the number of instances by policy – Min, Max,
Desired
Automatic Integration with ELB
Automatic distribution & balancing across AZs
Parameters for performing an Auto Scaling action
Scale Up/Down and by how much
ChangeInCapacity (+/- #) ExactCapacity (#)
ChangeInPercent (+/- %)
Cool Down (seconds)
Policy can be triggered by CloudWatch events
Launch Configuration Auto-Scaling Group Auto-Scaling Policy
![Page 88: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/88.jpg)
as-create-launch-config
--image-id ami-54cf5c3d
--instance-type m1.small
--key mykey
--group webservers
--launch-config 101-launch-config
Create a launch configuration:
![Page 89: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/89.jpg)
as-create-launch-config
--image-id ami-54cf5c3d
--instance-type m1.small
--key mykey
--group webservers
--launch-config 101-launch-config
Create a launch configuration:
The usual suspects
![Page 90: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/90.jpg)
as-create-auto-scaling-group 101-as-group
--availability-zones us-east-1a us-east-1b us-east-1c
--launch-configuration 101-launch-config
--load-balancers myELB
--max-size 5
--min-size 1
Create an auto scaling group:
![Page 91: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/91.jpg)
as-create-auto-scaling-group 101-as-group
--availability-zones us-east-1a us-east-1b us-east-1c
--launch-configuration 101-launch-config
--load-balancers myELB
--max-size 5
--min-size 1
Create an auto scaling group:
What’s going to launch
![Page 92: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/92.jpg)
as-create-auto-scaling-group 101-as-group
--availability-zones us-east-1a us-east-1b us-east-1c
--launch-configuration 101-launch-config
--load-balancers myELB
--max-size 5
--min-size 1
Create an auto scaling group:
Integrate with an ELB?
![Page 93: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/93.jpg)
as-put-scaling-policy 101ScaleUpPolicy
--auto-scaling-group 101-as-group
--adjustment=1
--type ChangeInCapacity
--cooldown 300
Create an auto-scaling policy (scale up):
![Page 94: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/94.jpg)
as-put-scaling-policy 101ScaleUpPolicy
--auto-scaling-group 101-as-group
--adjustment=1
--type ChangeInCapacity
--cooldown 300
Create an auto-scaling policy (scale up):
Period before another action will take place (Damper)
![Page 95: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/95.jpg)
as-put-scaling-policy 101ScaleDownPolicy
--auto-scaling-group 101-as-group
"--adjustment=-1"
--type ChangeInCapacity
--cooldown 300
Create an auto-scaling policy (scale down):
![Page 96: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/96.jpg)
CloudWatch Know what is going on
![Page 97: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/97.jpg)
![Page 98: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/98.jpg)
![Page 99: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/99.jpg)
CPU >= 50% for 5 mins
Takes action: Cloud Watch Alarm:
Scale up policy
CPU < 30% for 10 mins Scale down policy
![Page 100: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/100.jpg)
CPU >= 50% for 5 mins
Takes action: Cloud Watch Alarm:
Scale up policy
![Page 101: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/101.jpg)
CPU >= 50% for 5 mins
Takes action: Cloud Watch Alarm:
SNS Topic CPU < 30% for 10 mins
Send Email
Post to endpoint
Deliver message to Q
![Page 102: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/102.jpg)
CPU >= 50% for 5 mins
Takes action: Cloud Watch Alarm:
SNS Topic
![Page 103: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/103.jpg)
CloudWatch
Comprehensive Billing, technical, aggregate &
custom metrics
Alarms Set custom alarms
and thresholds
SNS Integration Push alarms to
SNS topics
HTTP Poke HTTP
endpoints for custom alarm
actions Custom Metrics
Write your own metrics in via SDKs
Email integration
Send alarm notifications to
emails
![Page 104: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/104.jpg)
Other topics to look at:
![Page 105: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/105.jpg)
Route 53
Front EC2 and ELBs with Route 53 for control over
DNS
Resource tagging
Tag resources like EC2 and have it appear on
billing reports
Rolling deployments
Use Route 53 and ELBs to do rolling deployments, A/B
testing
Other topics…
![Page 106: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/106.jpg)
OpsWorks
Manage stacks as layers and implement Chef
recipes to automate EC2 configuration
Beanstalk
Manage an entire autoscaling stack for
popular containers such as ruby, python etc
CloudFormation
Template everything from configuration of CloudWatch
alarms, SNS topics, EC2 instances
Other topics…
![Page 107: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/107.jpg)
Summary
![Page 108: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/108.jpg)
Stop doing these: Provisioning and fixing servers
Treating compute as physical things Thinking of compute as a finite commitment
![Page 109: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/109.jpg)
and start doing these
Security Build systems secure by
default
Elasticity Stateless autoscaling
applications
Replace not fix Build from scratch, don’t
fix something Unconstrained
Say goodbye to traditional capacity
planning
Be cost aware Tag resources, play with
instance types
Automation Create instances when you need them, drop
them when not
![Page 110: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/110.jpg)
Watch a demo here: http://youtu.be/kMExnVKhmYc
![Page 111: Masterclass Webinar: Amazon EC2](https://reader033.vdocument.in/reader033/viewer/2022050921/554bbddfb4c90594278b4f16/html5/thumbnails/111.jpg)
aws.amazon.com