More Related Content Similar to AWS Learning Webinar Spot Instances Benefits & Best Practices Explained (20) More from Amazon Web Services (20) AWS Learning Webinar Spot Instances Benefits & Best Practices Explained1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Chad Schmutzer, Solution Architect, Amazon Web Services
Jady Liu, DevOps Engineer, News Corp
19 October 2017
Spot Instances: Benefits and
Best Practices Explained
2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Ask the AWS Experts
Our Experts are online to answer any questions
you have during the presentation.
Ask your questions via the Questions Box on the
GoToWebinar Control Panel
3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Your Presenters
Chad Schmutzer
Solution Architect, AWS
Jady Liu
DevOps Engineer, News Corp
4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Are We Going to Do Today?
• Learn about Amazon EC2 Spot Instances
• Learn about EC2 Spot Instances best practices
• Understand tools for managing Spot Instances
• Customer Case Study: News Corp
5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
On-Demand
Pay for compute
capacity by the hour
with no long-term
commitments
For spiky workloads,
or to define needs
AWS EC2 Consumption Models
Reserved
Make a low, one-time
payment and receive
a significant discount
on the hourly charge
For committed
utilization
Spot Market
Bid for unused
capacity, charged at a
Spot Price which
fluctuates based on
supply and demand
For time-insensitive,
transient, or stateless
workloads
6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Spare Capacity at Scale
AWS has millions of active
customers, including a large
number of startups, enterprises,
and public sector organizations
running every imaginable use
case.
7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Are EC2 Spot Instances?
EC2 Spot instances are
spare EC2 On-Demand capacity
with very simple rules…
8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Are EC2 Spot Instances?
EC2 Spot instances are
spare EC2 On-Demand capacity
with very simple rules…
9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Very Simple Rules of Spot
Instances
10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Very Simple Rules of Spot Instances
Run in markets where the
price of compute changes
based on supply and
demand.
11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Very Simple Rules of Spot Instances
Run in markets where the price of
compute changes based on supply
and demand.
You’ll never pay more than your
bid. When the market exceeds your
bid you get 2 minutes to wrap up
your work.
12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Get the Best Value for EC2 Capacity
• Since Spot Instances typically cost 50-90% less than
On-Demand, you can:
13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Get the Best Value for EC2 Capacity
• Since Spot Instances typically cost 50-90% less than
On-Demand, you can:
• Increase your compute capacity by 2-10x within the same
budget.
14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Get the Best Value for EC2 Capacity
• Since Spot Instances typically cost 50-90% less than
On-Demand, you can:
• Increase your compute capacity by 2-10x within the same
budget.
• Save 50-90% on your existing workload.
15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Get the Best Value for EC2 Capacity
• Since Spot Instances typically cost 50-90% less than
On-Demand, you can:
• Increase your compute capacity by 2-10x within the same
budget.
• Save 50-90% on your existing workload.
• Or both!
16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Get the Best Value for EC2 Capacity
• Since Spot Instances typically cost 50-90% less than
On-Demand, you can:
• Increase your compute capacity by 2-10x within the same
budget.
• Save 50-90% on your existing workload.
• Or both!
• Either way, you should try it!
17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Understanding EC2 Capacity
AZ1
AZ2
(N. California) Total Capacity
P2 C4 M4 I3 R4 D2
Shared
Dedicated
Shared
Dedicated
x 2x 4x x 2x 4x x 2x 4x x 2x 4x x 2x 4x x 2x 4x
18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$0.27 $0.29$0.50
2b 2c2a
8XL
$0.30 $0.16$0.214XL
$0.07 $0.08$0.082XL
$0.05 $0.04$0.04XL
$0.01 $0.04$0.01L
C4
$1.76
On-
Demand
$0.88
$0.44
$0.22
$0.11
Capacity and Spot Markets Recap
us-east-2
19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$0.27 $0.29$0.50
2b 2c2a
8XL
$0.30 $0.16$0.214XL
$0.07 $0.08$0.082XL
$0.05 $0.04$0.04XL
$0.01 $0.04$0.01L
C4
$1.76
On-
Demand
$0.88
$0.44
$0.22
$0.11
• Each instance family
Capacity and Spot Markets Recap
us-east-2
20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$0.27 $0.29$0.50
2b 2c2a
8XL
$0.30 $0.16$0.214XL
$0.07 $0.08$0.082XL
$0.05 $0.04$0.04XL
$0.01 $0.04$0.01L
C4
$1.76
On-
Demand
$0.88
$0.44
$0.22
$0.11
• Each instance family
• Each instance size
Capacity and Spot Markets Recap
us-east-2
21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$0.27 $0.29$0.50
2b 2c2a
8XL
$0.30 $0.16$0.214XL
$0.07 $0.08$0.082XL
$0.05 $0.04$0.04XL
$0.01 $0.04$0.01L
C4
$1.76
On-
Demand
$0.88
$0.44
$0.22
$0.11
• Each instance family
• Each instance size
• Each Availability Zone
Capacity and Spot Markets Recap
us-east-2
22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$0.27 $0.29$0.50
2b 2c2a
8XL
$0.30 $0.16$0.214XL
$0.07 $0.08$0.082XL
$0.05 $0.04$0.04XL
$0.01 $0.04$0.01L
C4
$1.76
On-
Demand
$0.88
$0.44
$0.22
$0.11
• Each instance family
• Each instance size
• Each Availability Zone
• In every region
Capacity and Spot Markets Recap
us-east-2
23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
$0.27 $0.29$0.50
2b 2c2a
8XL
$0.30 $0.16$0.214XL
$0.07 $0.08$0.082XL
$0.05 $0.04$0.04XL
$0.01 $0.04$0.01L
C4
$1.76
On-
Demand
$0.88
$0.44
$0.22
$0.11
• Each instance family
• Each instance size
• Each Availability Zone
• In every region
• Is a separate Spot Market
Capacity and Spot Markets Recap
us-east-2
24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bid Price vs. Market Price
25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
You pay the
market
price
Bid Price vs. Market Price
26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
50% Bid
75% Bid
You pay the
market
price
25% Bid
Bid Price vs. Market Price
27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
50% Bid
75% Bid
You pay the
market
price
25% Bid
Bid Price vs. Market Price
Keep it simple and just bid 100% On-Demand price!
28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Instance Best Practices - Flexibility
Fault toleranceStateless Multi-AZ
Loosely
coupled
29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Instance Best Practices - Flexibility
Fault toleranceStateless Multi-AZ
Loosely
coupled
Instance
Flexibility
30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Instance Best Practices - Diversification
• Multiple EC2 Spot Instances selected
• Multiple Availability Zones selected
• Pick instance types with similar
performance characteristics. For
example: c4.large, r4.large, m4.large
31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Using a single
additional parameter
Run continuously
for up to 6 hours
Save up to 50% off
On-Demand pricing
EC2 Spot Blocks - Defined Duration
$1
32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Fleet
A single API call to help you…
33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Spot Fleet Helps You…
Launch Thousands of Spot Instances
with one RequestSpotFleet API call
Get Best Price
Find the lowest priced horsepower that works for you
or
Get Diversified Resources
Diversify your fleet – increase your availability
Apply Custom Weighting
Create your own capacity unit based on your application
needs
34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• We make this easy using the
Spot bid advisor
• With deliberate pool
selection and bidding, you
will keep your Spot instance
as long as you need to
• And with new features like
Spot fleet diversified we do
the heavy lifting for you...
Amazon EC2 Spot Bid Advisor
35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• We make this easy using the
Spot bid advisor
• With deliberate pool
selection and bidding, you
will keep your Spot instance
as long as you need to
• And with new features like
Spot fleet diversified we do
the heavy lifting for you...
Amazon EC2 Spot Bid Advisor
36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• We make this easy using the
Spot bid advisor
• With deliberate pool
selection and bidding, you
will keep your Spot instance
as long as you need to
• And with new features like
Spot fleet diversified we do
the heavy lifting for you...
Amazon EC2 Spot Bid Advisor
37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Labs on GitHub
38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Advisor in Console (New!)
39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2 Spot Advisor in Console (New!)
40. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Types of Workloads Are Customers Running
on Spot Instances?
• Queue and Batch based processing
• Hadoop / Spark / Big Data workloads (EMR)
• Stateless Applications (e.g. web tiers)
• CI/CD pipeline with the EC2 Spot Fleet Jenkins plugin
• Containerized workloads powered by Spot Fleet
• Live / Video On-Demand Streaming Content
41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Powering your Amazon ECS Cluster with Amazon
EC2 Spot Instances
42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Customer Case Study
Jady Liu, DevOps Engineer, News Corp
43. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lessons, Challenges, and Solutions
Q1: How do we register a Spot Fleet Instance to an ELB/ALB?
As there is no mechanism to automatically register a Spot Instance provisioned via a Spot Fleet Request with an ELB/ALB,
this needs to be implemented to distribute load across the fleet.
Q2: How do we associate an Elastic IP Address to a Spot Fleet Instance?
This will be required for services that need direct connectivity to the Internet such as NAT hosts and proxy servers.
Q3: How do we de-register a terminated Spot Instance from an ELB/ALB?
We need a mechanism to ensure that ELB traffic is not routed through to an instance that’s about to be terminated.
Q4: What happens if the Spot market price goes up beyond our bid price?
This needs to be considered if we are to have any guarantee of service, especially for production environments.
Q5: What happens if my workload runs on T2 Instance types?
There is currently no Spot markets for T2 instance types - meaning that workloads may have to run on m3.medium or
larger instance types to take advantage of Spot.
Q6: How do we automate all of this?
This needs to be considered if we are to have any guarantee of service, especially for production environments.
44. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Solution Going Forward: Deploy
Lambda Function
(InstanceTypes & Bids List)
Lambda Function
(Dynamic Spot Fleet Template)
Cloudformation
(Application Stack)
Lambda Function
(Conversion tool)
45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Solution Going Forward: Stack
Spot Fleet
Elastic Load Balancer
46. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Solution Going Forward: Stack
Spot Fleet On-Demand Fleet
Elastic Load Balancer CloudWatch Event
(1 minute Scheduled Rule)
Lambda Function
(TerminateEC2Instance)
47. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Solution Going Forward: Stack
Spot Fleet On-Demand Fleet
Elastic Load Balancer
CloudWatch Alarm
(EligibleInstancePoolCount)
CloudWatch Event
(1 minute Scheduled Rule)
Lambda Function
(TerminateEC2Instance)
Lambda Function
(ModifyOnDemandCapacity)
48. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Solution Going Forward: Stack
Spot Fleet On-Demand Fleet
Elastic Load Balancer
CloudWatch Alarm
(EligibleInstancePoolCount)
CloudWatch Event
(1 minute Scheduled Rule)
Lambda Function
(TerminateEC2Instance)
Lambda Function
(ModifyOnDemandCapacity)
CloudWatch Alarm
(Pending Capacity > 0 for > 5 min)
49. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
News Corp Business Impact
• Team adoption
• Current status
• Cost savings
50. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!
Getting started with EC2 Spot Instances:
http://aws.amazon.com/ec2/spot/
http://aws.amazon.com/ec2/spot/getting-started/
EC2 Spot Labs:
https://github.com/awslabs/ec2-spot-labs
51. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Q&A
52. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Additional Reference links
EC2 Spot Documentation:
http://aws.amazon.com/ec2/spot/
http://aws.amazon.com/ec2/spot/bid-advisor/
http://aws.amazon.com/ec2/spot/getting-started/
http://aws.amazon.com/ec2/spot/faqs/
http://aws.amazon.com/ec2/spot/testimonials/
User Guide
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-fleet.html
http://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-instance-fleet.html
Helpful AWS Blog Posts
https://aws.amazon.com/blogs/aws/focusing-on-spot-instances-lets-talk-about-best-practices/
https://aws.amazon.com/blogs/aws/building-price-aware-applications-using-ec2-spot-instances/
https://aws.amazon.com/blogs/compute/cost-effective-batch-processing-with-amazon-ec2-spot/
https://aws.amazon.com/blogs/compute/dynamic-scaling-with-ec2-spot-fleet/