Tuesday 18 July 2017

Tips on how to use Amazon EC2 spot instances


In this article, you will come to know how to use Amazon EC2’s Spot instances so that it can meet your computing needs. It can be a bit difficult to use Amazon EC2’s at the first but when you will perfectly get the hang of it and you will be resulted in saving cost up to 50% to 90%. There is one more you should keep in mind that Amazon can terminate the spot instances at any time for capacity reasons or price.



The following points will illustrate you on How to use Amazon EC2 Spot Instances:-

1.    First Plan either you want a long lived instances or a temporary:-

By choosing any spot instance you can’t expect it to work as long as you need. But there are spot instance if you want it for a long time. Long lived spot instances are kept for a long time so if such an instance gets terminated you can wait for the price to go down and use a different instance type or an availability zone. Spot instance is used for short time workloads which may be periodic can be spun when the market is good and they can be terminated once the work gets over.

a.    Spot instances can be run as programmatically or manually:-

Spot instances can also be set up for manual testing and development. Programmatic spot instances can run predefined applications and also execute predefined workloads.

b.    Frontend Instance should be handled with care:-

Spot instance that provides Frontend applications should be handled with care and on the other hand backend instances handle interruptions or launch failure so for that it is better to have a strategy.

2.    Identify different cases of spot request:-

There are different cases of Spot request you should understand. Spot request is opened right after it is first made. Persistent request open right after the spot instance is interrupted or terminated by Amazon. It will be active after it is configured by Amazon which will after the spot instance be created. It will state as failed if it is rejected by Amazon for the bad framework. If the request is expired then it will show as canceled. The spot request can be closed if the instance was interrupted by AWS and not specified to be persistent.

a.    Learn on how the request should be fulfilled:-

For every availability zone, instance type and operating system there are separate spot markets and each market there is also spot price. When the spot request is made the request will include the operating system, instance type and the availability zone with a bid price and also other options. After the spot request is fulfilled the user can’t make any changes except terminating the instance which will automatically cancel the spot request. The bid price should be equal or exceed the spot price; the spot request will be fulfilled but if the bid price is less compare to the spot price; the spot request will be rejected.

The Bid prices that exceed the spot price but the capacity is full then to make a place for that instance the other spot instance get terminated with first users who have the lowest bid price. The spot instances that get terminated are also called spot instance interruptions so that to differentiate from user initiated termination. Amazon notifies the users 2 minutes before so that the users itself can shut down properly. But there are also users that may terminate their own instances to free up the capacity so that the new instances can be created.

In short, the spot request will be fulfilled within some minutes of the spot request being made. For some instance, it may take the time to hours or even days for the spot request to be fulfilled.

b.    Pricing range of spot instance:-

The time that the spot request has fulfilled the instance will be charged for every hour at the present spot price by assuming it is equal or less to the bid price. If the user terminates the spot instances and uses it only for 15 minutes then still the user will have to pay for that particular hour. So if Amazon terminates the spot instances the user will not get charged for that hour. There may be also other reasons for the spot instance to get interrupted in the events of data center upgrades or maintenance without providing any advance notice. But there are some instances that are not available on the spot market.

3.    Use Spot Fleets:-

Spot fleet will provide you with the ability to set up multiple instance types. A spot fleet is a collection of spot instances where it helps in launching them to meet the target capacity.

4.    Use Autoscaling for spot instances:-

Before Autoscalling was first designed to manage variable traffic capacity but now it is possible to set up an autoscaling group of a fixed size. Autoscaling will provide the advantage of automatically spin up even when the spot instances get interrupted due to capacity reasons or pricing or any other reasons. Operating Autoscaling with CloudFormation will be very helpful for managing upgrades or any changes done to your configuration.

5.    Compare the spot instances pricing by the availability zone:-



By comparing the spot instance pricing history by the availability zone you will come to know about the structure of the pricing history in the market. You will find some places where the prices are high all the time. You can also identify that the price spikes in different availability zones in different times.

6.    Always keep a check on the spot instances cost:-

In Amazon EC2 console you can get a breakdown of the instance cost by region, instance type, purchase option, and availability zone. You can also use a filter to see the cost of the instance type. By setting up the billing alert to the root account it will start sending the data to the Amazon CloudWatch.







No comments:

Post a Comment

Maximizing Content Delivery Efficiency: Optimizing Performance in AWS CloudFront

  Unleash Blazing-Fast Content Delivery: Your Guide to CloudFront Optimization Introduction: AWS CloudFront stands as a cornerstone of moder...