Taffel.se is currently hosted at a Swedish shared hosting provider (Oderland). We’ve been very pleased with the price and quality of their service, but with a shared host there are naturally limits to what is possible to build. Since Taffel.se is (in practice, although not in principle) a non-commercial site, I haven’t had time to spend much time developing it. But we’ve got some new ideas that we’d like to try, including some improvements that couldn’t be implemented on the shared server. Renting a server is very expensive for a project that doesn’t make money, an order of magnitude more than what we’re paying now, especially if I want someone to take care of making backups. So I decided to look into Amazon’s EC2 offering. After a few days playing with it, I have to say wow! EC2 seems to offer all of the advantages of having your own server and none of the disadvantages. It’s very cheap, and making backups of your data is trivial. And you can have as many test servers as you want. As long as you don’t keep them running when you’re not using them it doesn’t cost much.
For those of you that don’t know, EC2 (elastic computing cloud) allows users with an Amazon account to create virtual servers on demand, based either in Europe or in the US. Each server is based on a machine image (AMI) which you can create yourself or you can use one of the thousands of freely available images created by Amazon or other users. An image is basically a linux/unix installation (Windows is available at a higher cost) which can be customized for a specific purpose. You can create as many instances from an image as you like. The storage on a virtual server is ephemeral, meaning that it only exists as long as the instance is running (storage survives rebooting as long as you don’t terminate an instance). For persistent storage you can create an elastic block store (EBS) which is like a virtual disk that you can attach to an instance (you can even create several and combine them into a RAID). The data on an EBS doesn’t go away when you terminate the instance. Even better, you can take a snapshot of an EBS, a process that takes seconds and stores a copy of everything on the disk in Amazon’s S3 storage service. You can create copies of an EBS based on a snapshot and attach them to new instances. And it works incredibly quickly.
I chose to use 2 EBS volumes, one for databases and other application data, and one for source code. That way I can easily make changes on a test server instance and try it out with the most recent data from the production server. Brilliant! Instead of creating my own AMI I’m using an official Ubuntu AMI with a minimal install. I’ve written a shell script that starts an instance, installs all of the software I need using apt-get (that way I never need to worry about updating software – I can just start a new instance now and then), creates EBS volumes from snapshots, attaches them and mounts the volumes in all the right places. So in about 10 minutes I can have a new server with everything working. Well, almost everything. I have everything from Taffel.se running on a test server except mail. I’m no expert on configuring mail servers, so this may take a little while, but this article seems like a good start. As soon as I have everything working Taffel.se is moving to EC2.
I’m very impressed with Ubuntu as well. Setting up a Linux server is incredibly easy these days (although of course I didn’t have to do it from scratch). An excellent resource for using Ubuntu on EC2 is Alestic.com. Eric Hammond from Alestic wrote this very useful article on EBS and MySQL as well as this script for taking consistent snapshots of EBS volumes with databases on them. Lots of other useful stuff as well.