// you’re reading...

servers

Exploring Amazon Elastic Compute Cloud (EC2)

This week I’ve been reading a great deal about Amazon EC2, a service which lets you rent servers from Amazon’s huge server farms from as little as 10 cents/hour ($73/month).

The principle behind EC2 is genius. You select which ‘AMI’ (linux image) you want to start your server with, then choose what spec you want.

Here’s the server specs you can choose from:

$0.10 - Small Instance (Default)
1.7 GB of memory, 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit), 160 GB of instance storage, 32-bit platform

$0.40 - Large Instance
7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each), 850 GB of instance storage, 64-bit platform

$0.80 - Extra Large Instance
15 GB of memory, 8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each), 1690 GB of instance storage, 64-bit platform

So, what’s useful about EC2?

There are countless uses for Amazon’s EC2 Service, but it fairs particularly well as a scalable webserver solution. Here’s how you would use EC2 for a scalable webserver.

Firstly, we set up a ’small’ instance with a base install of ubuntu.
Then, we SSH in and install all the packages we need for our LAMP install.
We checkout our code from the SVN repo, and set a cron to regularly update the codebase.

Once we have our server environment set, you can create an ‘AMI’ (linux image) of this setup, so you can use it again.

Now, we start growing our groovy web service, and need some more power.
So, we launch a new instance with the base ubuntu and install mysql on it. Then, move the database from our first server over, and start offloading all the mysql requests to our new instance.

So, there’s the Apache/MySQL seperation done.
Now, we can scale some more, until, it’s time to add another webserver.
This is where EC2 makes things really easy. We just start a new instance, and use the AMI we created earlier. Within minutes you have a new webserver running identically to your first.

Add a round-robin into the DNS, and we’re good to go.

There is also the option to create your instances in specific geographic locations for redundancy purposes (EC2 has had a few outages in the past).
So, you could build several LAMP clusters around the world without being tied into long-term server contracts, fixed server specs, and high upgrade costs which come with most dedicated server hosting options.

Amazon really are switching on to the whole scalable, flexible hosting solutions… and with new features like ‘persistent storage’ (mount a linux volume, which is accessible from any of your instances), and elastic IPs (static IP which can be forwarded to any of your instances), EC2 is probably one of the most flexible services around.

If you’ve not already looked into it, I’d recommend giving it a full trial. You could really save on time, money, and headaches by using it instead of tradition dedicated server companies.

If you’re interested in testing EC2, I’d recommend this article at paulstamatiou.com to help you get started.

Notes: Persistent Storage is still in private beta and will not support access across multiple instances from day 1. Until then, you could look at PersistentFS

Discussion

2 comments for “Exploring Amazon Elastic Compute Cloud (EC2)”

  1. I knew about Amazon S3 and it’s uses for the web; but I never considered using Amazon EC2 this way.

    I always thought it was more geared towards ‘power users’ and their calculations: huge linear calculations and that sort of stuff…

    Thnx for the pointer!

    Posted by Jakob Buis | April 15, 2008, 10:32 pm
  2. Great post!

    Your write “Add a round-robin into the DNS, and we’re good to go”, is that all part of EC2’s services or is that something that has to be handled seperatly?

    Posted by Andreas Krohn | May 16, 2008, 8:34 am

Post a comment