How to avoid billing for EC2 for unused time?

I have a periodic task that I need to run on EC2. It will not take more than 10 minutes to complete this task, and I don’t want to pay this task for 50 minutes for downtime. From my point of view, if I run an instance and run this task, regardless of whether I use any resources or not, I will be billed for my use. So I was looking to do something on the following lines every 60 minutes or so (just a high-level sketch):

def invokeTimer(i): if timer(i) expired: copyDataFromNode(i) killNode(i) while True: for i in range(1,10): startNode(i) # Allow the node to boot up startScript(i) invokeTimer(i) sleep(60000) 

Assuming I was able to convey my idea, is there a good way to implement this in a clean way, or perhaps a tutorial that can help?

+4
source share
2 answers

You will pay for the whole hour no matter what you do.

As soon as you start an instance of EC2 (you call it nodes, but this is wrong), you pay for an hour. Any hour hour is paid as a full hour.

If you clicked on the AMI (backup image) of the machine, you have to pay for the amount of EBS, so there is a cost.

It is best to use spot copies to save money on regular copies.

+5
source

Try picloud and pay per second.

+7
source

All Articles