Thursday, September 9, 2010

running Ubuntu on an Amazon "micro" instance

Amazon announced today a new instance type. The "micro" instance type (t1.micro) has 613 MB of memory and can be used with AMIs of either x86 or x86_64. The cost for either is only $0.02 per hour.

That means that you can try out Ubuntu on EC2 for 2 measly cents. The official images of Ubuntu 10.04 LTS (Lucid Lynx) are perfect for this. If you're more adventurous and want to try out 10.10, please try out a daily build.

I think this smaller instance size really makes EC2 available to a lot more people. The minimum price for running an instance for a month goes from something like $70 (31 * 24 * 0.095) to less than $15. If you add to that the fact that you can shut down the instance and not be charged for unused CPU time, then start it back up when you need it, it can be really cheap. If you happen to need more CPU power, you can even shut it down, and start it back up with more resources!

So what are you waiting for!

$ MY_LAUNCHPAD_ID="smoser"
$ printf "#cloud-config\n%s\n" "ssh_import_id: [${MY_LAUNCHPAD_ID}]" > user-data.txt
$ ec2-run-instances --region us-east-1 --user-data-file=user-data.txt ami-1234de7b


A few things to note:
  • Bug 634102 has to be worked around or you will not be able to reboot your instance. There are cloud-init debs available in my personal PPA with fixes. 10.10 won't have the issue, and I'll work on getting the fix backported to 10.04.  You can easily fix that by running:

    arch=$(uname -m)
    [ "$arch" = "x86_64" ] && ephd=/dev/sdb || ephd=/dev/sda2
    sudo sed -i.dist "\,${ephd},s,^,#," /etc/fstab

  • One interesting feature of this instance type is that it will run images that are x86 or x86_64 arch. Previously each instance type only ran a single arch.
  • Above, I launched the instance with cloud-config syntax that will pull in my keys from launchpad rather than using public ssh keys stored in EC2. Thats why I didn't need to pass '--key <mykey>'

edits

  • I fixed the ami id above, I had listed a instance-store image.  Also, a thing to note is that with t1.micro instances you *have* to use EBS images.
  • I fixed the 'sed' command above, and fixed the price for m1.small (0.095, not 0.95)

13 comments:

  1. Hi,
    just a note : monthly price for small ec2 will be about 700 USD ( 31*24 is about 700, no 70 ), so for small it will 150 $/month. So it's still more expensive than dedicated :-/

    ReplyDelete
  2. oops, I made a mistake in 10 times. 15 usd really cool point!

    ReplyDelete
  3. I am new to EC2 but looking to jump in with a Micro install. How far out do you think the patch for 10.04 will be?

    I imagine there will be custom AMI created for the micro instances eventually. Are there any downsides to using a small AMI for a micro instance at this point?

    ReplyDelete
  4. I can't seem to find a way to launch a micro instance in eu-west (using the console)... is it possible?

    ReplyDelete
  5. @Phil,
    It certainly should be possible to launch an instance in eu-west-1, but I'm not certain if you can do it from the console or not.
    I just verified:
    eu-west-1 ami-38bf954c canonical ebs/ubuntu-lucid-10.04-i386-server-20100827
    ec2-run-instances --region eu-west-1 --instance-type t1.micro ami-38bf954c

    ReplyDelete
  6. @dflydev
    The patch for bug is in the -proposed archive at the moment. It should make it to -updates for lucid by the end of the week, and I hope to refreshed images soon after.

    Regarding using micro instances, yes. I would absolutely recommend playing with a t1.micro instance, and if you find that you need more you can move up. If you expect that you would need to grow *really* large, then you should probably use x86_64. The only reason to not do that is that there is quite a jump in price from t1.micro to m1.large (0.02 to 0.38 per hour) while m1.small is 0.085 or 0.09 per hour.

    ReplyDelete
  7. Uf. All this afternoon trying to understand this problem... install new kernel, and instance do not restore up condition, puaj!

    Easy to resolve with your 3 code lines!

    Thank you Scott

    ReplyDelete
  8. http://mdabusufian.blogspot.com এখানে আপনি পাবেন ইন্টারনেট, মোবাইল, সফটওয়ার, হার্ডওয়ার সংক্রান্ত অনেক প্রয়োজনীয় টিপস। আরো পাবেন বিভিন্ন সফটওয়ার এর কিজেন একদম ফ্রি। এ ছাড়াও পাবেন অনলাইনে আয়ের খবর ও পদ্ধতি।
    http://mdabusufian.blogspot.com Here you can find a lot of technology tips, free software, key and system of online earning.

    ReplyDelete
  9. Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it microsoft azure tutorial , because you have explained the concepts very well. It was crystal clear, keep sharing..

    ReplyDelete