Wednesday 12 June 2013

AWS_Amazon_Spot_Instance

AWS: Amazon spot instance:

The purpose of using an Amazon Spot instance is for:
1. To save money (it’s cheaper to run servers on Amazon as Spot instances) 
2. To make recovering a failed instance very fast and easy.

Q1. How this is cheaper?
Few example: 

http://www.youtube.com/embed/WD9N73F3Fao?rel=0&hd=1
http://www.youtube.com/embed/BD1X5ItelOk?rel=0&hd=1

Because, even if we have bid for the higher price, its charges for the current spot price. 

Example: 
1. A linux c1xl server's current bid price is $0.070 [ 7 cents only per hour ]
2. The On demand price is around $0.50 [ 50 cents per hour]

and out bid price is $0.75 [ 75 cents per hour ] which is higher even the on demand price, but how its can cost less? Because its charge on the current spot price [ which is 7 cents now]. Then why we are requesting for that high bid price [ around 75 cents ] even higher then spot price?

Note that, the spot instance goes away if some one bid in higher price, so when we have our bid price is more then the on-demand price, then most likely we have a higher chances that out hosts will not go down, and the spot price stay much lower then on demand price for a longer time. Hence we save an overall money and a higher chances of getting the spot instance for longer time.

For more details, please follow the above youtube links.

A Spot Instance on Amazon is how customers can ‘bid’ for unused capacity on Amazon’s infrastructure. The cost to run a Spot Instance is always fluctuating. As long as that cost is below the maximum ‘bid’ price that we bid, then the server continues to run.  However, when Amazon has system issues, network issues, etc, then the current Spot Instance price will go up, exceeding our maximum bid price. When this happens, the server will be terminated instantly without any warning.  Therefore, Spot Instances are useless for things like a Database Server. And they are only useful for areas of the product that are designed to take advantage of them.

AWS wiki link: http://aws.amazon.com/ec2/spot-instances/ [ Further details ]




Spot Instance Issues
A Spot Instance has to be set up in a special way in order for it to work correctly.

When our maximum ‘bid’ price is exceeded, the server will be terminated. Then, when the current price drops back below our maximum bid price, the server will be re-launched. When it is re-launched, it’s like it was launched for the first time: it gets a new InstanceId, all data is lost, etc. Therefore, any data that must be retained has to be on a separate EBS volume.

Also, the IP addresses that the spot instance uses will also change when it is re-launched. This causes issues for both monitoring and for database access, since the server’s IP address is used for both.

This means that the Spot Instance must have boot-up scripts that:
- mount an /ebs volume where the data is stored,
- all data that we change on a regular basis (Apache Document Root, etc) must be links from the root disk to locations under /ebs
- we must assign an Elastic IP address when the instance boots up, so it gets the same public IP address and Amazon DNS name each time it is re-launched. The Amazon DNS name will not change, but the Private IP Address that it resolves to *does* change.


No comments:

Post a Comment