EBS Boot Instance Stop+Start Begins a New Hour of Charges on EC2

Scott Moser and I were wondering if stopping and starting an EBS boot instance on EC2 would begin a new hour’s worth of charges or if AWS would not increase your costs if the stop/start were done a few minutes apart in the same hour.

For some reason, I had assumed that it would start a new hour of fees, possibly because of my experience with the somewhat unrelated terminating old instances and starting new instances. However, we decided it would be easy to test, so here are the results.

I tested with an Ubuntu 10.10 Maverick 32-bit server EBS boot AMI on the m1.small instance type in the ap-southeast-1 (Singapore) region. The AMI should have no effect on charges, so these results should apply to any OS you run on EC2.

I used an AWS account that did not have any EC2 instance fees in the Singapore region that month (Scott’s idea) so that this activity would be easy to see as the only charges on that account.

$ ec2-run-instances --region ap-southeast-1 --key KEYPAIR ami-6a136d38
RESERVATION r-48370d1a  063491364108    default
INSTANCE    i-908782c2  ami-6a136d38            pending KEYPAIR 0   m1.small    2010-10-14T16:38:17+0000    ap-southeast-1a aki-13d5aa41    monitoring-disabled                 ebs         paravirtual 
$ ec2-stop-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  running stopping

$ ec2-start-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  stopped pending
$ ec2-stop-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  running stopping

$ ec2-start-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  stopped pending
$ ec2-stop-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  running stopping

$ ec2-start-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  stopped pending
$ ec2-terminate-instances --region ap-southeast-1 i-908782c2
INSTANCE    i-908782c2  running shutting-down

You can see that I had four begin/end sessions where the instance was running; all of these took place in a single real time hour. Before stopping, I waited each time for the instance to move to running, and I waited each time for the instance to move to stopped before starting it again.

I then waited for a while (hours) for the results of this activity to show up on the AWS account activity page.

activity snapshot

If Amazon considered all of this activity to be taking place by a single instance in a single hour real time hour then the charge would have been $0.095 (m1.small in the ap-east-1 region). However, Amazon considers each of these run sessions to be starting a new hour of charges, so I was charged for 4 hours of instance time at $0.38.

In general, this additional charge is not a big deal. After all, for the smaller instance types we are only talking pennies or dimes for an hour of instance time. However, if you set up some sort of system where you are constantly stopping and starting instances within a single hour of wall clock time, then the effects of this policy could multiply your costs. You might want to investigate ways to keep your instances running more continuously and only stopping them if the anticipated down time is more than an hour.

Update: After I ran this test I found that Shlomo Swidler answered this question on the EC2 forum, but it’s still fun to prove it.