Thursday, 30 December 2010

Getting started with Amazon Web Services (AWS)

I am about to launch a new website - more about that in another article. The site is nearly finished (or at least in a state ready for launch). However, I need to get in place the hosting for it as from experience I want to be aware of the problems before rather than after the site is launched.

I've looked at a few options in the last year or so, from shared hosting to dedicated servers to virtual servers and using cloud based services (for things like SQL). Still not sure what I'd do long term. From my time at GTI I know about running a network centre and configuring and using servers.

I've recently joined the Microsoft Website Spark program and found lots of suppliers giving access to dedicated servers for a lower price whilst you are part of the program. But it's not that much cheaper, and it is for the most expensive option - dedicated servers.

Anyway what I need is a Windows 2008 Server running SQL Server. SQL Server express will operate with my new site quite happily, although part of Website Spark gets me SQL Server Web Edition.

For the moment I've chosen Amazon Web Services (AWS) using their Elastic Computing Cloud (EC2). A friend of mine at Swirrl recommended this to me. You basically pay as you go - so if things don't work out then I'm not stuck in a 12 month agreement.

Amazon describe their service as "a web service that provides resizeable compute capacity in the cloud". I'm not too sure I agree with that completely - you buy a share of a large server and can do with it as you want (mostly). Unlike, say Azure you aren't consuming that as a service. At the moment not too sure I'm that comfortable letting go of the control of a server to using a service. I currently host my home website using shared hosting, where all you can do is upload files (via FTP) so I was really looking forward to being in control again.

Amazon operate four network locations (with multiple "availability zones" within each location) giving good redundancy options (if you want to use them). Two of these are on different sides of the USA one in Asia and one in Ireland. The prices for using each location is similar, although the centre in the Virginia seems slightly cheaper. I choose to use the one in Ireland, but nothing to stop me using another later.

I had a server up and running in less than 20 minutes after signing up. The sign up process involves giving over your credit card number and receiving an automated call from Amazon to verify your phone number. From there you are presented with a web site (the AWS console) and can create an instance.

I am using a service called EC2 - the Elastic Computing Cloud. It really means that you create server instances, that you can repeat (i.e. have multiple instances), that you can load balance (using Elastic Load Balancing). Their are several storage options, including EBS - Elastic Block Storage, where you can purchase more storage when you need to or copy your current volumes.

AWS Console
For what I am doing, I simply need a server to provide a web site - not too worried about load balancing (which gives not just capacity but some disaster recovery). I am (for the moment) going to run a few web sites on the one server.

Amazon provide a number of instance types. This is probably one of the biggest drawbacks of the Amazon service in that you are pigeon-holed into a certain process capacity. The elastic part if that you can add more instances, however, for a small site you have a choice of the instances called t1.micro and m1.small. The configuration of these are

Micro - 613MB memory, Up to 2 EC2 compute units (for short bursts)
Small - 1.7GB memory, 1 EC2 compute unit

One EC2 Compute Unit is described as being the equivalent CPU capacity of a 1.0-1.2 GHz 2007 Opteron or 2007 Xeon processor or early-2006 1.7 GHz Xeon processor. For my small application in terms of running as a web server I'm really not that worried about the processing power. The Micro instance seems more suited to a web server as it can "burst" to using more power. However, it is expected that the processor usage will generally be less than 1 unit. The biggest difference is in memory and this is my biggest worry. Can I get a (Windows) server (with SQL Server) running in around 600MB of memory. The key to AWS is that you pay for what you use - so if it doesn't work out I can move to a Small instance or a different provider.

But, what about the cost. Amazon do provide a sort of pay in advance option (called Reserved Instances) where you pay a fee in advance for an instance, and then the pay as you go price is lower. I am currently using an On-Demand Instance, where for a Micro instance I am paying USD 0.035 per hour (For a small instance the cost is nearly four times as much). For a reserved instance the cost will be USD 0.016 per hour - half the price, but you pay either USD 54 for 1 year or USD 82 for a 3 year term. (Note that once you pay your upfront fee, you don't need to actually host anything). Amazon also provide a service called Spot instances where you effectively bid for instances, which will reflect Amazon's spare capacity and will be available at a cheaper price than the on-demand instances. However, from what I read you need to be aware that the capacity may be taken away at any time (as the capacity is needed elsewhere).

You also pay for your storage as well as the bandwidth in and out. For the first year a lot of this cost is fairly covered as a discount is provided. A Micro instance running Windows works out about USD 26 per month and bandwidth/storage hopefully only another couple of dollars. (If you want a micro instance running Linux then AWS really gives it to you for nearly free for a year). There is a decent calculator on the Amazon website to work out your costs.

Getting a server up and running was fairly painless. The documentation is very good and easy to work through. From the console you choose launch a new instance and choose from a number of Amazon Machine Images, which are good templates. I choose a 32-bit Windows 2008 R2, with SQL Server Express. Within 10 minutes it was set-up.

A bit of security is needed where a key pair is created. Once created you then paste in your private key to a window which will decrypt the administrator password. You also need to set-up a firewall (or security rules). This means getting the IP address of your broadband connection and setting this up so that only you can remote desktop to the server.


The next step is optional, I didn't do it initially but wish I did. When an instance is started it is given an IP address. If the instance is stopped (i.e. you aren't paying for it) then when you start it up again later you get a different IP address. What you need to setup is called an Elastic IP Address. This is associated with your account. When an instance is started you can then relate the IP address with an instance. Elastic IP addresses are free - until they aren't associated with any instance, when you pay 1 cent per hour. If you are going to be running a website 100% of the time then it shouldn't be a problem. You can use this IP address for your DNS setup.

Logon to your instance using remote desktop and setup your server. I'll write about that in the next post.

No comments:

Post a Comment