SlideShare a Scribd company logo
1 of 32
Download to read offline
AutoSpoting - an automated EC2
spot market bidder
GDG Berlin Golang - Clowdy Gophers
30 May 2016
Cristian Măgherușan-Stanciu
HERE Maps, Berlin
About me
SysAdmin at HERE Maps, Berlin, supporting maps.here.com(https://maps.here.com)
Background: networking, Linux, AWS, C/Shell/Perl/Ruby/Python
Passionate about automation
Spare-time gopher for a few months now, and I love it
Agenda
The idea
Implementation details
Challenges and future plans
Conclusions
Q&A
The idea
AWS Spot Market Automation
Needed a non-trivial problem for learning Go in my spare time
First discussed on an AWS Berlin meet-up
Interesting, it got me thinking
Decided to 'go build' it in my spare time
AutoSpoting
Simple solution to reliably use the AWS spot market, for production use-cases
Easy to use
Simple design and implementation
Maximize cost savings without sacri cing high availability
AWS Spot Market - Intro
Unused EC2 capacity sold to the highest paying bidders
Prices based on supply/demand
Considerable variation per region, instance type and even availability zone
Not all of them are available on the market
AWS Spot Market - Typical Prices, Savings and Risks
Starts from 10% the on-demand price, peaks as high as 10x
Savings >80% of on-demand are common, or ~5x capacity for the same costs
But spot instances are terminated with a 2 minute notice when outbid!!!
m3.large in Virginia, last 30 days
AWS Spot Market - Challenges
Instances could be terminated at any time
The application must be designed with this in mind
Not applicable for everything
Rewards cloud'y designs
AWS Spot Market - Achieving High Availability with Manual Bidding
Place large bids and hope for the best
Spread over multiple pricing zones
Carefully pick region, instance type and availability zone
AWS o ers helper tools
AWS Spot Bid Advisor
AWS Spot Market - Automation Bidding Solutions
AWS o ers just building blocks
AutoScaling native integration - supports a single instance type
SpotFleet - entirely di erent API, has some limitations (scaling, ELB...)
Also there are many 3rd party & custom tools
My Solution - AutoSpoting
Leverage recent autoscaling features to replace on-demand instances with spot
equivalents
Spread over multiple instance types in each availability zone
AutoScaling handles instance terminations and ELB integration for the spot
instances
Easy to install and con gure against existing AutoScaling groups
Serverless and low overhead
Implementation details
Architecture
Work ow - Request New Spot Instance
Work ow - Swap Instances
After the spot instance has been running for longer than the group's grace period
Work ow - Swapped Instances
Work ow - Terminate On-Demand Instance
Work ow - Instance Replaced
Work ow - Loop until done
Repeat this until we have no on-demand instances left in the group
Work ow - Final State
Algorithm details
The Lambda JavaScript shim automatically updates to the latest released binary
that is implementing all the logic and runs it
The Go program downloads data describing instance specs and on-demand
pricing (compiled by ec2instances.info)
Goroutines are then processing in parallel all the regions and enabled groups
The spot instance type and bid price are determined for each group, based on the
on-demand running instances and current spot prices
Instance replacement is performed as described in the work ow
High Availability
Spot instance termination, when outbid
Handled by AutoScaling like any instance failure
AutoScaling will launch on-demand instances to compensate for lost capacity
Those will in turn be replaced with spot instances later, as per the work ow
Low likelihood of service downtime, with enough pricing zones and redundancy
Installation details
Easy deployment via CloudFormation stack
Enable/disable per AutoScaling group using a custom tag, o by default
Have a look on my my blog(http://mcristi.wordpress.com)for detailed installation instructions
Challenges and future plans
Challenges
Needs automated testing, currently I mostly do it manually
Automated testing needs some internal redesign (WIP)
Still trying to gure out testing with the AWS SDK for Go
How to do table-structured tests with big/mocked data structures
Future Plans
Finish preparing for automated testing
Write tests
Use information about termination likelihood from the Spot Bid Advisor
Make some parameters of the algorithm con gurable
React on the 2min termination notice, with code running on spot instances
Allow keeping some on-demand capacity if con gured
Open source the code
Conclusions
What I like about Go
Easy to learn
Easy refactoring
Easy to do concurrency
Error handling
Static binaries allow me to deploy easily
If you also have an interesting idea, 'go build' it!
Questions and Answers
Thank you
Cristian Măgherușan-Stanciu
HERE Maps, Berlin
cristian.magherusan-stanciu@here.com(mailto:cristian.magherusan-stanciu@here.com)
https://mcristi.wordpress.com(https://mcristi.wordpress.com)
@magheru_san(http://twitter.com/magheru_san)

More Related Content

Similar to Autospoting - an automated EC2 spot market bidder

(CMP311) This One Weird API Request Will Save You Thousands
(CMP311) This One Weird API Request Will Save You Thousands(CMP311) This One Weird API Request Will Save You Thousands
(CMP311) This One Weird API Request Will Save You ThousandsAmazon Web Services
 
Cloudreach Voices EC2 Making Sense of the Cost Options
Cloudreach Voices EC2 Making Sense of the Cost Options  Cloudreach Voices EC2 Making Sense of the Cost Options
Cloudreach Voices EC2 Making Sense of the Cost Options Cloudreach
 
This One Weird API Request Will Save You Thousands
This One Weird API Request Will Save You ThousandsThis One Weird API Request Will Save You Thousands
This One Weird API Request Will Save You ThousandsAmazon Web Services
 
AWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep diveAWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep divePeter Shi
 
Cut AWS Costs: Using Spot Instances for More Than Batch
Cut AWS Costs: Using Spot Instances for More Than BatchCut AWS Costs: Using Spot Instances for More Than Batch
Cut AWS Costs: Using Spot Instances for More Than BatchRightScale
 
An introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - WebinarAn introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - WebinarCMPUTE
 
AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...
AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...
AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...Amazon Web Services
 
Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...
Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...
Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...Amazon Web Services
 
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...Cobus Bernard
 
Introduction to Amazon EC2 Spot
Introduction to Amazon EC2 Spot Introduction to Amazon EC2 Spot
Introduction to Amazon EC2 Spot Amazon Web Services
 
AWS Cloud cost optimization
AWS Cloud cost optimizationAWS Cloud cost optimization
AWS Cloud cost optimizationYogesh Sharma
 
Getting Started with EC2 Spot - November 2016 Webinar Series
Getting Started with EC2 Spot - November 2016 Webinar SeriesGetting Started with EC2 Spot - November 2016 Webinar Series
Getting Started with EC2 Spot - November 2016 Webinar SeriesAmazon Web Services
 
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...Amazon Web Services
 
How to Reduce your Spend on AWS
How to Reduce your Spend on AWSHow to Reduce your Spend on AWS
How to Reduce your Spend on AWSJoseph K. Ziegler
 
AWS APAC Webinar Series: How to Reduce Your Spend on AWS
AWS APAC Webinar Series: How to Reduce Your Spend on AWSAWS APAC Webinar Series: How to Reduce Your Spend on AWS
AWS APAC Webinar Series: How to Reduce Your Spend on AWSAmazon Web Services
 
Optimizing Costs and Efficiency of AWS Services
Optimizing Costs and Efficiency of AWS Services Optimizing Costs and Efficiency of AWS Services
Optimizing Costs and Efficiency of AWS Services Amazon Web Services
 
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot InstancesWorkshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot InstancesAmazon Web Services
 
Leveraging elastic web scale computing with AWS
 Leveraging elastic web scale computing with AWS Leveraging elastic web scale computing with AWS
Leveraging elastic web scale computing with AWSShiva Narayanaswamy
 

Similar to Autospoting - an automated EC2 spot market bidder (20)

Reduce Your Cloud Spending With AWS Spot Instances
Reduce Your Cloud Spending With AWS Spot InstancesReduce Your Cloud Spending With AWS Spot Instances
Reduce Your Cloud Spending With AWS Spot Instances
 
(CMP311) This One Weird API Request Will Save You Thousands
(CMP311) This One Weird API Request Will Save You Thousands(CMP311) This One Weird API Request Will Save You Thousands
(CMP311) This One Weird API Request Will Save You Thousands
 
Cloudreach Voices EC2 Making Sense of the Cost Options
Cloudreach Voices EC2 Making Sense of the Cost Options  Cloudreach Voices EC2 Making Sense of the Cost Options
Cloudreach Voices EC2 Making Sense of the Cost Options
 
This One Weird API Request Will Save You Thousands
This One Weird API Request Will Save You ThousandsThis One Weird API Request Will Save You Thousands
This One Weird API Request Will Save You Thousands
 
AWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep diveAWS Cost Opt Meetup 2 - News corp - Spot On deep dive
AWS Cost Opt Meetup 2 - News corp - Spot On deep dive
 
Cut AWS Costs: Using Spot Instances for More Than Batch
Cut AWS Costs: Using Spot Instances for More Than BatchCut AWS Costs: Using Spot Instances for More Than Batch
Cut AWS Costs: Using Spot Instances for More Than Batch
 
An introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - WebinarAn introduction to Spot Instances and AWS Fleet - Webinar
An introduction to Spot Instances and AWS Fleet - Webinar
 
AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...
AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...
AWS re:Invent 2016: Dollars and Sense: Technical Tips for Continual Cost Opti...
 
Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...
Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...
Coding Apps in the Cloud to reduce costs up to 90% - September 2016 Webinar S...
 
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
AWS EMEA Online Summit - Blending Spot and On-Demand instances to optimizing ...
 
Introduction to Amazon EC2 Spot
Introduction to Amazon EC2 Spot Introduction to Amazon EC2 Spot
Introduction to Amazon EC2 Spot
 
Introduction to Amazon EC2 Spot
Introduction to Amazon EC2 SpotIntroduction to Amazon EC2 Spot
Introduction to Amazon EC2 Spot
 
AWS Cloud cost optimization
AWS Cloud cost optimizationAWS Cloud cost optimization
AWS Cloud cost optimization
 
Getting Started with EC2 Spot - November 2016 Webinar Series
Getting Started with EC2 Spot - November 2016 Webinar SeriesGetting Started with EC2 Spot - November 2016 Webinar Series
Getting Started with EC2 Spot - November 2016 Webinar Series
 
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
 
How to Reduce your Spend on AWS
How to Reduce your Spend on AWSHow to Reduce your Spend on AWS
How to Reduce your Spend on AWS
 
AWS APAC Webinar Series: How to Reduce Your Spend on AWS
AWS APAC Webinar Series: How to Reduce Your Spend on AWSAWS APAC Webinar Series: How to Reduce Your Spend on AWS
AWS APAC Webinar Series: How to Reduce Your Spend on AWS
 
Optimizing Costs and Efficiency of AWS Services
Optimizing Costs and Efficiency of AWS Services Optimizing Costs and Efficiency of AWS Services
Optimizing Costs and Efficiency of AWS Services
 
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot InstancesWorkshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
 
Leveraging elastic web scale computing with AWS
 Leveraging elastic web scale computing with AWS Leveraging elastic web scale computing with AWS
Leveraging elastic web scale computing with AWS
 

Recently uploaded

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Recently uploaded (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

Autospoting - an automated EC2 spot market bidder

  • 1. AutoSpoting - an automated EC2 spot market bidder GDG Berlin Golang - Clowdy Gophers 30 May 2016 Cristian Măgherușan-Stanciu HERE Maps, Berlin
  • 2. About me SysAdmin at HERE Maps, Berlin, supporting maps.here.com(https://maps.here.com) Background: networking, Linux, AWS, C/Shell/Perl/Ruby/Python Passionate about automation Spare-time gopher for a few months now, and I love it
  • 3. Agenda The idea Implementation details Challenges and future plans Conclusions Q&A
  • 5. AWS Spot Market Automation Needed a non-trivial problem for learning Go in my spare time First discussed on an AWS Berlin meet-up Interesting, it got me thinking Decided to 'go build' it in my spare time
  • 6. AutoSpoting Simple solution to reliably use the AWS spot market, for production use-cases Easy to use Simple design and implementation Maximize cost savings without sacri cing high availability
  • 7. AWS Spot Market - Intro Unused EC2 capacity sold to the highest paying bidders Prices based on supply/demand Considerable variation per region, instance type and even availability zone Not all of them are available on the market
  • 8. AWS Spot Market - Typical Prices, Savings and Risks Starts from 10% the on-demand price, peaks as high as 10x Savings >80% of on-demand are common, or ~5x capacity for the same costs But spot instances are terminated with a 2 minute notice when outbid!!! m3.large in Virginia, last 30 days
  • 9. AWS Spot Market - Challenges Instances could be terminated at any time The application must be designed with this in mind Not applicable for everything Rewards cloud'y designs
  • 10. AWS Spot Market - Achieving High Availability with Manual Bidding Place large bids and hope for the best Spread over multiple pricing zones Carefully pick region, instance type and availability zone AWS o ers helper tools AWS Spot Bid Advisor
  • 11. AWS Spot Market - Automation Bidding Solutions AWS o ers just building blocks AutoScaling native integration - supports a single instance type SpotFleet - entirely di erent API, has some limitations (scaling, ELB...) Also there are many 3rd party & custom tools
  • 12. My Solution - AutoSpoting Leverage recent autoscaling features to replace on-demand instances with spot equivalents Spread over multiple instance types in each availability zone AutoScaling handles instance terminations and ELB integration for the spot instances Easy to install and con gure against existing AutoScaling groups Serverless and low overhead
  • 15. Work ow - Request New Spot Instance
  • 16. Work ow - Swap Instances After the spot instance has been running for longer than the group's grace period
  • 17. Work ow - Swapped Instances
  • 18. Work ow - Terminate On-Demand Instance
  • 19. Work ow - Instance Replaced
  • 20. Work ow - Loop until done Repeat this until we have no on-demand instances left in the group
  • 21. Work ow - Final State
  • 22. Algorithm details The Lambda JavaScript shim automatically updates to the latest released binary that is implementing all the logic and runs it The Go program downloads data describing instance specs and on-demand pricing (compiled by ec2instances.info) Goroutines are then processing in parallel all the regions and enabled groups The spot instance type and bid price are determined for each group, based on the on-demand running instances and current spot prices Instance replacement is performed as described in the work ow
  • 23. High Availability Spot instance termination, when outbid Handled by AutoScaling like any instance failure AutoScaling will launch on-demand instances to compensate for lost capacity Those will in turn be replaced with spot instances later, as per the work ow Low likelihood of service downtime, with enough pricing zones and redundancy
  • 24. Installation details Easy deployment via CloudFormation stack Enable/disable per AutoScaling group using a custom tag, o by default Have a look on my my blog(http://mcristi.wordpress.com)for detailed installation instructions
  • 26. Challenges Needs automated testing, currently I mostly do it manually Automated testing needs some internal redesign (WIP) Still trying to gure out testing with the AWS SDK for Go How to do table-structured tests with big/mocked data structures
  • 27. Future Plans Finish preparing for automated testing Write tests Use information about termination likelihood from the Spot Bid Advisor Make some parameters of the algorithm con gurable React on the 2min termination notice, with code running on spot instances Allow keeping some on-demand capacity if con gured Open source the code
  • 29. What I like about Go Easy to learn Easy refactoring Easy to do concurrency Error handling Static binaries allow me to deploy easily
  • 30. If you also have an interesting idea, 'go build' it!
  • 32. Thank you Cristian Măgherușan-Stanciu HERE Maps, Berlin cristian.magherusan-stanciu@here.com(mailto:cristian.magherusan-stanciu@here.com) https://mcristi.wordpress.com(https://mcristi.wordpress.com) @magheru_san(http://twitter.com/magheru_san)