Using spot instances

Instances used for experimentation, learning, and in highly price-sensitive situations, using spot instances can be the most cost-effective option. These instances offer incredible value for the right workloads and are commonly used for dev/test, and embarrassingly parallel workloads. AWS carries extra capacity in terms of unused instances, and they sell these instances on a spot market. The pricing is dynamic and based on supply/demand. If you check the price history of spot instances, you will note that they do not vary too much. Hence, you can balance price and availability with the right combination of On-Demand, Reserved, and Spot instances.

You can set the maximum price you want to pay for an instance, and that price can be much lower than the regular on-demand price (the price difference can sometimes be as high as 90%). If capacity is available, then Amazon will fulfill that request. However, your instance is terminated (with 2 minutes notice), if the spot price is higher than your price. If your application is architected against failures, then such terminations should not impact the running of your application.

Availability and costs can vary between different AZs. When the demand goes up, the price can go even higher than on-demand instances. To guard against this situation, you need to set your price carefully and start your instances in another AZ, if the price in your current AZ goes higher than your set price. For example, you can set your spot price to be greater than the market rate and less than the on-demand prices to always get the market rate, at or under your bid price.

Spot instances give you an opportunity to name your own price, and they can potentially save you 80-90% on your instance costs. But understand and plan for the risks associated with using them. You can leverage auto scaling to reduce your overall risks. For example, you can create two auto scaling groups: one with on-demand instances and the other with Spot instances. As Spot instances are not always guaranteed, you can set a CloudWatch alarm on the number of Spot instances in the group and auto scale the on-demand group, if the number of spot instances is below the threshold you set. The spot instances fleet saves you a lot of money automatically; while the fleet of on-demand instances scales up to compensate for any terminated spot instances. This way, you can have the best of both worlds—lower costs while maintaining a HA architecture. You can use 2 minutes available during the termination of spot instances for running scripts to write out any data, log files, and so on. 

Spot instances are a great choice for stateless web/app server fleets, Amazon EMR, continuous integration, high-performance computing (HPC), grid computing, media rendering/transcoding, and so on use cases. You can also run batch jobs using AWS batch service that leverages spot instances.

The Spot Bid Advisor can tell you—how likely it is that you will lose your instances against other bids (for a given instance type and number of instances). If the likelihood is low over the past 1 month, then you are likely to keep your instances.

So far, we have primarily focused on cost savings related to EC2 instances. However, Amazon S3 offers additional opportunities to cut storage costs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.75.236