Using amazons elastic compute cloud for buildstarted com
After a few outages of my previous host I’ve decided to move my server to Amazon’s EC2 services. I have to tell you it was not an easy transition. I was more than confused with the array of options on Amazon’s services.
I’m going to go over exactly the choices I’ve made and what I did to get it working.
Type of machine
This site isn’t the most popular on the internet so I don’t need anything really powerful. Here are the systems available for websites:
|Micro||613MB||Up to 2 ECUs (for short periodic bursts)||EBS only||32 or 64 bit|
|Small||1.7 GB||1 ECU (1 Virtual core with 1 EC2 Compute Unit)||160 GB local storage||32 or 64 bit|
|Large||7.5 GB||4 ECUs (2 virtual cores with 2 EC2 Compute Units each)||850 GB local storage||64 bit|
|Extra Large||15 GB||8 ECUs (4 virtual cores with 2 EC2 Compute Units each)||1690 GB local storage||64 bit|
I’ve decided to go with the Micro server. It’s cheap (currently free for one year) and it fits my needs. I haven’t had another asp.net referral for a while though (hint, hint) so I might need to upgrade to a small server when that time comes. Incidentally that’s one of the great things about Amazon’s service: I can change the server type at a whim without reconfiguring the system.
AMI’s or Amazon Instance Machines are the bases for any system you wish to start up on EC2. There are a wide range of over 6000 different systems available on the Community AMI list from Windows to Linux and even OpenSolaris to custom server types like a default wordpress and joomla setups. I chose a blank Ubuntu setup as that is what I’m familiar with and I know what I’m getting since I’ll be forced to install everything myself.
Setting up your new machine
The first step in setting up your new machine is to choose what type of instance you want.
You have a selection, based on your chosen ami, of what type of machine you want. This is really powerful as a single AMI can be any type of system you want. So if your site is small - like this one - but it gets really popular you can either add new instances of the same type for load balancing or you can just change the type of machine your instance runs on. I can’t figure out how the hell they do this but it’s damn awesome.
I have no clue exactly what this is. I just use the default Kernel and RAM Disks. Here you can enable CloudWatch which allows you to see detailed information on disk/ram/network usage while your machine is running.
Here you can add some tags. The default one of Name always works well. Tags are really only useful if you have a lot of different instances in your list and you want to quickly find instances based on a particular attribute.
Here you can create a key pair for remote access to your system. This doesn’t require you to remember a username or password - which, as we’ve seen with the recent Gawker incident, is never a good idea. Store your keypairs in a safe place. When you ssh with a client such as PuTTY you’ll set your auth to your keypair you’ve created here.
Setting up your instance firewall allows you to open ports to your instance and make it available to the internet or a select ip range. I’ve opened up HTTP and SSH here as all I would need is a cheap web server and nothing more. Though I’ve selected All Internet for both options I would recommend you only use a port range for something like SSH. But for testing, who cares? :)
This page is just a review of what you’ve selected on the previous pages with the option to go back and make changes if you screwed up somehow. If everything is good you just need to click Launch.
All Micro Instances must be stored using EBS. I didn’t know what this meant at first but I understand now. I did a lot of extra stuff after I setup my server such as backing up my wordpress database once a day and restoring the database on boot. I found that this isn’t necessary as EBS instances are more permanent and store stuff on your EBS storage. This does introduce possible other costs but this website exists mostly in cache so it’s not really an issue. For instance-only storage for some AMI’s any changes to the filesystem do not persist when the machine is shut down. This is a very important distinction. Since you can use Instances for stuff other than hosting, like data processing, it may or may-not be necessary.
|Costs||Linux Hour||Windows Hour||Linux Year||Windows Year|
The above costs are for instances that haven’t been reserved. Windows costs are all slightly more per hour than Linux.
|Reserved Costs||1 Year||3 Years||Linux||Windows||Linux Year||Windows Year|
The above costs are for reserved instances. You can purchase an instance ahead of time, such as a small, for a one time fee. In return you get a discount price per hour for the length of your purchase. Windows prices may fluctuate over the course of your contract, however. I was thinking about reserving a Micro instance as the savings is quite significant over the course of 3 years at a savings of over 50%. However, thinking about it more and more…if this site gets more popular over time I may need to change from Micro to Small - in which case my reserved instance is no longer the savings machine it was. Just something to think about. I doubt I’ll need anything more than my Micro but you never know…it’s up to the community to make me upgrade. However, doing the math, even if I needed to upgrade the server from Micro to Small in 6 months I would still save money by reserving an instance.
I won’t do that though - the Micro is currently free to new subscribers to Amazon’s EC2 service
As I learn more about this process I will post more. This whole setup has brought up some questions that I’m sure I’ll find the answers for over time (I’ll probably head over to serverfault.com and ask them!) I’m currently finalizing another site that I intend to host on Amazon’s EC2 service that will be much more popular. (I hope) So I should have a chance to test stuff like upgrading the server to a more powerful machine and what not to see how that works.