Learning Objectives:
- Understand key Spot concepts and common usage patterns for maximum cost optimization in the cloud
- Learn how to deploy services on maximum scale at minimum cost using EC2 Spot
- Leverage lower compute costs to better compete on price and, as a result, winning more business
Companies of all sizes want to reduce the time and cost to perform complex analysis, process massive amounts of data, or batch jobs by leveraging AWS. Amazon EC2 Spot Instances allow you to grow your application’s compute capacity and throughput up to tenfold for the same budget. We will cover reference architectures for many common workloads running on Amazon EC2 Spot today, including building a CI/CD pipeline with the Amazon EC2 Spot Fleet Jenkins plugin and powering your ECS cluster with Spot fleet for accelerated processing in AWS.
2. What are we going to do today?
• Learn about EC2 Spot Instances
• Understand EC2 capacity
• Learn about EC2 Spot Instances best practices
• See a couple customer examples
• Understand tools and partners for managing Spot
instances
• See a couple of demos
• Q & A
3. 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
4. Spare Capacity at Scale
AWS has millions of active
customers every month,
including more than 2,300
government agencies, 7,000
education institutions and more
than 22,000 nonprofit
organizations that have used
AWS in the last 12 months.
5. What are EC2 Spot instances?
EC2 Spot instances are
spare EC2 On-Demand capacity
with very simple rules…
6. 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.
7. 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
• Or you could save 50-90% on your existing workload
• Either way, you should try it!
9. Speaking of Dedicated Instances…
http://amzn.to/2jnfzmj
• Same pricing as shared
tenancy!
• No $2/hour per region fee!
10. $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
13. EC2 Spot best practices - Diversification
• Multiple EC2 Spot instances selected
• Multiple Availability Zones selected
• Pick the instances with similar
performance characteristics e.g.
c3.large, m3.large, m4.large, r3.large,
c4.large
14. My instances cannot be interrupted!
~ 21% less than 1 hour
~ 35% less than 2 hours
~ 40% less than 3 hours
In total roughly 50% of all instances
live less than 6 hours
15. Using a single
additional parameter
Run continuously
for up to 6 hours
Save up to 50% off
On-Demand pricing
EC2 Spot Blocks
$1
18. Customer examples – Yelp
• Seagull is Yelp’s distributed system for concurrent task execution
• Seagull’s infrastructure costs were reduced by 85% by moving to
Spot instances
Seagull
Infrastructure
Cost
Timeline (May 2015-April 2016)
55% reduction in costs after initial transition to
spot instances
Additional 60% savings after
transition to spot +
autoscaling complete
21. 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
22. EC2 Spot fleet – significant features added
Weighted Bidding for EC2 Spot Instances [Aug 31,
2015]
Distribute Your Fleet Across Multiple Capacity Pools
[Sep 15, 2015]
New Spot Console [June 16, 2016]
Auto scaling for Spot fleet [Sept 01, 2016]
New Spot advisor in Console [Feb 27, 2017]
23. An easy to use interface that
lets you launch spare EC2
instances in seconds
Helps you select and bid on the
EC2 instances that meet your
applications requirements
Simple to use dashboard lets
you modify and manage your
application’s compute capacity
EC2 Spot Console
24. 1) We make this easy using the
Spot bid advisor
2) With deliberate pool
selection and bidding, you
will keep your Spot instance
as long as you need to
3) And with new features like
Spot fleet diversified we do
the heavy lifting for you...
Amazon EC2 Spot Bid Advisor
28. Capitalizing on two minute warning
• When the Spot price exceeds your
bid price, the instance will receive
a two-minute warning
• Check for the 2 minute spot
instance termination notification
every 5 seconds leveraging a
script invoked at instance launch
29. Sample script – two minutes left!
$ if curl -s http://169.254.169.254/latest/meta-
data/spot/termination-time |
grep -q .*T.*Z; then instance_id=$(curl -s
http://169.254.169.254/latest/meta-data/instance-id);
aws elb deregister-instances-from-load-balancer
--load-balancer-name my-load-balancer
--instances $instance_id;
/env/bin/flushsessiontoDBonterminationscript.sh; fi
1. Check for 2 minute
warning
2. If YES, detach instance
from load balancer
3. OTHERWISE, do
nothing
4. Sleep for 5 seconds
30. Let’s see Spot fleet with Auto Scaling in
action...
• Queue and Batch based processing
• Live / Video On-Demand Streaming Content
• Stateless Applications (e.g. web tiers)
• CI/CD pipeline with the Amazon EC2 Spot Fleet Jenkins
plugin
• Amazon EC2 Container Service powered by Spot fleet
31. Batch Processing with Amazon EC2 Spot
Batch oriented applications can leverage on-demand
processing using EC2 Spot to save up to 90% cost:
Monte Carlo
simulation
Molecular
modeling
Media
processing
High energy
simulations
32. Common method Batch Processing
Once completed, the objects will be uploaded back to S3 using multi-part upload
Each job can be further split into multiples sub-parts if there is a mechanism to
stitch the outputs together
Store the input objects in a file system such as Amazon Elastic File System
(Amazon EFS), local instance store or Amazon Elastic Block Store (EBS)
Worker nodes get job parts from the SQS and perform single tasks based on the
job task state in DynamoDB
36. Stateless Web Application
Elastic Load
Balancing
Stateless
Web Servers
(Spot)
Stateless
Web Servers
(Spot)
Session
State Data
Spot fleet
Availability Zone A
Availability Zone B
Stateless
Web Servers
(Spot)
Stateless
Web Servers
(Spot)
37. Results - Web Application
• 50 instances
requested, over 30
days
• Never dropped
below 45 instances
• 85% discount if
you wanted 50 and
could withstand
dropping to 45
0
0.02
0.04
0.06
0.08
0.1
0.12
30
35
40
45
50
55
Instances Average Price Per Instance
• If you only wanted
45 the discount is
still 83%