Recently, Amazon.com announced that they were offering software developers and small businesses a full year of Amazon Elastic Cloud Computing (EC2) for free. I’ve been wanting to dig into cloud computing for some time. And, being human, I regard “free” as too good a price to pass up.
Signing up for EC2 was the easy part. Once signed up, I found myself deluged by a stream of new concepts and acronyms. In this series of articles, I’ll attempt to untangle the concepts behind EC2, and provide a step by step guide to hosting content on your new EC2 account.
How Cloud Computing Differs from Virtual Hosting
The best way to understand cloud computing is to understand how it differs from a virtual hosting account with a company such as Dreamhost or Hostgator. From a mile-high standpoint, both are providing a similar service: hosting your Web applications (HTML, PHP, .NET, Ruby on Rails, or what have you) on a server or servers maintained in a data center. Both relieve your company of the hassle of creating its own high-speed network and maintaining its own data center.
Where the two services differ dramatically is in the speed of scalability. With a virtual hosting account, you pay for tiers of performance and bandwidth. If you think your performance and network needs will be small, you can get by with a cheap virtual hosting account. If your demands exceed those needs, you’re forced to pay to rent a dedicated server. If your Web site soars in popularity, you’ll have to contract with your provider for a second dedicated server. Upgrading capacity with a virtual host can take days; meanwhile; your Web site is getting hammered, and you’re losing business due to poor performance and a lack of connections.
With cloud computing, you are renting processor time and storage in a virtually limitless execution environment. Cloud computing providers will automatically scale your available capacity to meet your demand. Unlike virtual hosting, where you pay for excess capacity regardless of whether you use it, you pay for only the execution capacity and bandwidth you actually use. Your application can start with 100 users per day, and scale seamlessly to 100,000 or 1 million.
How EC2 Works
EC2 runs your Web applications in a virtual machine instance. This instance is created using an Amazon Machine Image (AMI) configuration. You can launch as few or as many virtual servers as your application needs, scaling the number of servers up or down as its needs demand.
What makes Amazon.com’s cloud computing initiative unique is that EC2 supports a number of different operating system images. You can run Linux, Suse Enterprise Linux, Microsoft Windows Server 2008, or CentOS Cluster Server. You can also purchase access to a unique AMI from a third party vendor. For example, Zend sells an AMI of Zend Server CE, their server optimized for PHP execution.
Starting and Connecting to Your EC2 Instance
I’m assuming you’ve signed up for an account. Like I said, signing up for EC2 is the easy part. It’s the EC2 dashboard screen that takes some navigating for first-time users. The EC2 dashboard screen bombards users with an alphabet soup of techno-jargon – S3, EC2, VPC, RDS, etc. Let’s ignore the acronyms for the time being and answer the simplest question: how do I create and log in to a server?
First, you will need to create a new virtual server instance. If you log in to the EC2 screen, you’ll see a prominent button that says Launch Instance. Click it, and you will be prompted to select an operating system for your virtual server. For this article, we’re going to host a SuSE Enterprise Linux server.
[NOTE - ADDED 11/22/2010: SuSE Linux is NOT part of the free hosting plan. You will be charged instance hours for using it. You should use a micro instance of the Basic 32-bit Amazon Linux AMI instead. I will demonstrate how to use this in my next article.]
EC2 walks you through several options for configuring your virtual server. The most important for our purposes is Create Key Pair, which allows you to generate a public/private key combination for connecting to your virtual server. Generate a key and save it to your local computer; we’ll use this key in a short while to log into the server we’ve just created.
Accept the defaults for all of the other options, and you will be ready to work with your new virtual server.
Logging in to Your Virtual Server
Click on Instances on your EC2 Dashboard, and you should see your server running. The question now is: how do you log into it?
EC2 lets us establish an SS H connection from a Windows SSH client such as PuTTY. Before we can do this, however, we need to configure our server to open up connections on port 22. We’ll accomplish this by opening up port 22 on our default security group. Click Security Groups on the left hand side on the EC2 Web page, and select default. To add support for SSH, select SSH in the drop-down at the bottom of the page. Add 22 for the From Port and the To Port, and for Source (IP or group), add 0.0.0.0/0.
To log in to our instance using PuTTY, we have to use our EC2 key pair. However, Putty won’t work directly with the keys that EC2 generated for us. Fortunately, we can download PuTTYGen to convert our .pem key file into a format that PuTTY can process. Once you’ve downloaded PuTTYGen, click File->Load Private Key to load the .pem file. Then click Save Private Key to save a .ppk file that can be used by PuTTY.
In PuTTY, we can select this .ppk file in the Connection->SSH->Auth menu to use it as our private key login for our EC2 virtual server.
All we’re missing now is an address for our server! To obtain the public address for your server instance, go to the Instances page, select your running instance, and scroll down to the bottom of the page. Copy the value you find in the Public DNS field, and use this in the Host Name or IP field on PuTTY’s Terminal login screen. When prompted for a username, enter root. PuTTY will use your private key to log you in to your virtual server.
We have successfully signed up for Amazon.com EC2, created a virtual server, and logged in to our server. In our next article, we’ll start exploring the directory structure of our new server, and will discover how to host a basic HTML Web site on Apache.
Latest posts by Jay Andrew Allen (see all)
- Creating New Linux Users and Login Keys on Amazon EC2 - December 22, 2010
- Upload Files to Your Amazon EC2 Server using WinSCP - December 16, 2010
- How to Point a Domain to an Amazon EC2 Virtual Server - December 8, 2010