Skip to content

Collection of tools and code examples to demonstrate best practices in using Amazon EC2 Spot Instances.

License

Notifications You must be signed in to change notification settings

danylohetmantsev/ec2-spot-labs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ec2-spot-labs

ec2-spot-labs is a collection of code examples and scripts that illustrates some of the best practices in using Amazon EC2 Spot Instances.

get_spot_duration.py

get_spot_duration.py helps find capacity pools (defined as instance type and AZ) with lower price volatility by ordering these pools based on duration of time since the Spot price last exceeded the bid price. It uses AWS CLI to programmatically obtain Spot price history data.

Input:

  • AWS EC2 region
  • product-description
  • combination of instance types and Spot bids prices for each instance type.

For example, for c3 family and bids equal to 50% of On-demand price:

bash-3.2$ python get_spot_duration.py \
--region us-east-1 \
--product-description 'Linux/UNIX' \
--bids c3.large:0.05,c3.xlarge:0.105,c3.2xlarge:0.21,c3.4xlarge:0.42,c3.8xlarge:0.84 


Duration        Instance Type   Availability Zone
168.0   c3.8xlarge      us-east-1a
168.0   c3.8xlarge      us-east-1d
168.0   c3.8xlarge      us-east-1e
168.0   c3.4xlarge      us-east-1b
168.0   c3.4xlarge      us-east-1d
168.0   c3.4xlarge      us-east-1e
168.0   c3.xlarge       us-east-1d
168.0   c3.xlarge       us-east-1e
168.0   c3.large        us-east-1b
168.0   c3.large        us-east-1d
168.0   c3.large        us-east-1e
168.0   c3.2xlarge      us-east-1b
168.0   c3.2xlarge      us-east-1e
117.7   c3.large        us-east-1a
36.1    c3.2xlarge      us-east-1d
34.5    c3.4xlarge      us-east-1a
23.0    c3.xlarge       us-east-1b
21.9    c3.2xlarge      us-east-1a
17.3    c3.8xlarge      us-east-1b
0.1     c3.xlarge       us-east-1a

Notes:

  • Availability Zone mapping may be different for different AWS accounts
  • 168.0 means that Spot price hasn't exceeded specified bid during last week (168 hours by default)
  • Actual numbers will be different, script uses last 1-week of price history and Spot prices change continiously based on supply and demand
  • Newer accounts that are VPC by default may not see all purchase options and only see ( "Linux/UNIX", "SUSE Linux", "Windows" )

Please see get_spot_duration.py --help for additional options.

Issues

Please address any issues or feedback via issues.

About

Collection of tools and code examples to demonstrate best practices in using Amazon EC2 Spot Instances.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.8%
  • Shell 42.7%
  • Dockerfile 2.5%