About two years ago, we published tiopatinhas “An AWS Autoscaling companion that saves money by using instances from the Spot Market”®. In short, Tiopatinhas replaces half of your autoscaling ondemand instances with instances from the spot market. That allows you to save above 33% of EC2 costs depending on the instance type.
Now diving into the details, tiopatinhas is a python script that connects to an autoscaling group, monitors cloudwatch data and spot market information. Based on that information, tiopatinhas decides when to launch or terminate an instance via autoscale. If it detects that your application needs to be scaled, it checks if the next instance should be spot or on-demand: in the first case, it bids on the market, launches the instance and attaches it to the autoscaling group and ELB. Otherwise, autoscaling takes over and does the job.
Tiopatinhas is smart: when the spot market crashes, it replaces it’s spot instances with on-demand ones so that your application does not need to wait for the autoscaling triggers to scale out, which could take a while depending on the cooldown period of your policies. Also, if the market is “flapping”, tiopatinhas is aware of the one-hour billing cycles of AWS, so it won’t waste your money trying to replace instances in the middle of an hour. Moreover, tio patinhas is fail-safe: if the tiopatinhas process crashes, it will leave some instances in the autoscaling group, but since it doesn’t change any of your autoscaling rules, there is no risk of it crashing your entire application environment.
The graph below compares the number of ondemand (green) vs spot instances (yellow) in a live autoscaling group. It’s possible to see that there are roughly the same amount of spot and ondemand instances (ignore the spikes =]). So in this example, about 50% of the autoscaling instances are running at lower spot market prices ($$$$).
In some recent changes, we added the option to use different instance types, useful for when the spot market is too volatile for one specific instance type. If you use, for example, a c1.xlarge instance and it’s spot market is crashing often, you can use a larger instance with a spot price still lower than the on-demand ones. We have some plans of supporting an heterogeneous cluster, with many different instance types to avoid a crash of half of your instances at once in case of a failure, stay tuned :)
We currently run tiopatinhas in many production systems at Chaordic. To get started, just run:
python tp.py -g <AutoScalingGroupName>
Does this sound interesting and you think it could be fun to work with us? Please have a look on our careers page.