Spot fleet is good, but it may not fit every use case. E.g you can not easily shutdown the non-prod environment with spot fleet, due to its scalable target only allows 1 – 3000. In some scenarios, running autoscaling group on spot instance is a better way to go.
And essentially, it is all about the launch configurations and spot instance request. I developed a bot (named Huggies) to manipulate it. Here is a quick demo.
This is how a typical autoscaling group looks like. Lets say I name my autoscaling group as newsapi-jackie for convenience.
Now I am telling Huggies to use spot instance for my environment by giving the bidding request (bid m1.small for 0.001 per hour).
Under the hood, Huggies makes a copy of the existing launch configurations then add the bidding parameters into it.
To spin up new instances, I need to tell Huggies to start my environment.
Start/Stop environment is just a matter of updating the minimum and maximum size of the autoscaling group.
However my bid price $0.001 is too low to get a m1.small instance. But fortunately Huggies is smart enough to know it, and make a new bid price for me.
How does Huggies know it?
Huggies logs it as:
What if I want to change back to on-demand instance or the spot instance is out of capacity?
Huggies will switch back to the original launch configuration if spot instance is out of capacity or user asks so.