Cloud Computing Basics: Getting Started With Amazon EC2
What Can You Do In A Cloud?Let's say you have a great idea for a new website. But it's a complicated idea, one that might take a number of interconnected servers for security or database reasons. Perhaps you're not sure how much disk space or RAM it might actually need to work optimally. And you have a pretty good idea that it might really take off and become popular. All this sounds like it could be great, but signing lease agreements for what might be an open-ended number of hardware servers is going to be lots more expensive than you'd like, and you don't want to tie up (or lose) a lot of cash on a yet-unproven idea.
So what if you could easily add and pay for servers of almost any size when you needed them, and pay nothing when you didn't? What if you could set up automatic load balancing between servers, and automatic scaling (adding or subtracting servers as necessary) when that wasn't enough? What if you only paid for the storage you needed (with automatic scaling here too, of course) and the bandwidth/data transfer you actually used?
If you were around in the 1970s, think "Time Sharing On Steroids". But cloud computing is not drugs or black magic, simply virtual servers running on high-performance hardware, with most of the details hidden so you can concentrate on software.
OK, Sign Me Up!We chose Amazon as the showcased vendor for this series because they have a very comprehensive set of cloud computing offerings, their rates are reasonable with no monthly minimums, and you don't have to be a big company just to talk to them. In fact, you don't even have to talk to them, just sign up online.
The first thing you'll need is an Amazon Web Services (AWS) account. If you already either buy from Amazon or have an affiliate account with them, you can use your current login or start up a new one, but you'll have to go to this page and agree to all the terms. AWS has an almost dizzying array of offerings; the one we want is called EC2 (Elastic Compute Cloud), which you must sign up for separately.
You'll be paying less than 10 cents/hour (at current 2010 rates) for a small default Linux-type server, plus an extra charge (around 10 cents/gigabyte) for data transfer. AWS calls each separate instance of a virtual server an Instance, and you can choose Instances optimized for heavy CPU use, high amounts of RAM, and even cluster computing. These will cost more money, of course, but you can add them any time you like.
There are a few steps necessary to get one of these Instances started, so we'll do it slowly. After the first time, it will be easier and more familiar, and you'll also have certain things already saved from before. The first step after all your signing up, providing payment details, and so on is to log into the AWS Management Console (AKA The Dashboard):
Click "Launch Instance" and you'll see a subwindow with a list of AMIs. The AMI (Amazon Machine Image) is the format used to package an entire operating system with preinstalled software in such a way that it will be independent of the actual storage capabilities, RAM, and even the CPU configuration of the hardware it's running on. That way, you can select a particular hardware configuration when you boot up the AMI. It's a virtual machine image that's been customized to work on Amazon's cloud hardware architecture.
Diversity is the watchword here. You can pick almost any flavor of operating system you can think of as a pre-configured AMI (all stored in the cloud, naturally), or even upload your own if you wish.
For the purposes of this article, not to mention Amazon support and general familiarity, we'll choose one of the basic systems on the first (Quick Start) tab: a Fedora-based LAMP system (Linux/Apache/MySQL/PHP):
Choosing these options now will minimize your costs while you are learning the ropes:
A few more pages follow (if in doubt, use the default settings). You'll be asked to set up and name a Key Pair, which is simply an encrypted file that will let you sign in securely and authenticate yourself later; make sure the resulting .PEM file is stored in a handy spot on your computer. You'll also have to set up a Security Group, which is Amazon's name for a firewall configuration. Just make sure it has at least these three basic definitions:
When you've finished configuring your Instance, it will look something like this:
If everything looks good, select "launch" and hang on! Your instance will be starting, and you'll get a prompt to view your Instances window, which you should open:
Your Instance is now running. Congratulations! Now, connecting to it securely is a different task entirely, and we'll learn how to do that in the very next article. Until then, you should right-click the Instance and terminate it, which stops AWS from charging you any more money (so far, less than $0.10) until you launch another one.