Online Book Reader

Home Category

Facebook Cookbook - Jay Goldman [57]

By Root 662 0
S3 is to storage, EC2 is to hosting (see Amazonian Backends: Simple Storage Solution). You can realize some pretty dramatic cost savings by hosting on EC2, particularly if your app needs to scale suddenly to meet demand.

Discussion


Setting up and running an EC2-based hosting system isn’t any easier than doing it the old-fashioned way, but it sure is cheaper. If you don’t have experience administering Linux-based systems, you might want to skip this approach or find a friend (or new employee) who does. There’s a pretty thorough tutorial on setting up and using AWS with Facebook available at http://tinyurl.com/2fs9f6 (Amazon really needs to do something about the URLs on its website).

Getting started is pretty simple: if you don’t already have an AWS account, you can sign up for one at http://www.amazonaws.com. You’ll then need to add EC2 to your Amazon Web Services by visiting the EC2 page (http://ec2.amazonaws.com) and clicking on the big “Sign Up For This Web Service” button on the right side (Figure 5-10).

Figure 5-10. Can you guess what this button does?

You’re going to need an S3 account to go along with your EC2 account, since EC2 stores and retrieves your Amazon Machine Images (AMIs) from S3. That will make more sense in a moment, but in the meantime you should go add S3 to your AWS account at http://s3.amazonaws.com.

Amazon will email you when your servers are available, so in the meantime you should make yourself an X.509 certificate. According to Wikipedia (http://en.wikipedia.org/wiki/X.509):

In cryptography, X.509 is an ITU-T standard for a public key infrastructure (PKI) and Privilege Management Infrastructure (PMI). X.509 specifies, amongst other things, standard formats for public key certificates, certificate revocation lists, attribute certificates, and a certification path validation algorithm.

Amazon uses X.509 certificates to authenticate you when you connect to your server over SSH or SFTP. If you already have a certificate, you can upload it at http://tinyurl.com/6jbnbu. If you don’t, it provides a service for creating a new certificate, which you can access at http://tinyurl.com/5dm5cb. That page will produce two files that you should download and store very securely: your Private Key file and your X.509 Certificate. Create a directory called .ec2 in your home directory of your computer, and put those two files into it.

You’ll need to figure out your EC2 username, which is your Amazon account number with the hyphens removed. If you don’t have your account number, you can get it by selecting “AWS Account Activity” from the yellow “Your Web Services Account” menu, as shown in Figure 5-11.

Your account number will be listed at the top of the page, and it should take the form 1234-1234-1234. Drop the hyphens, and there you have your EC2 username (123412341234).

Figure 5-11. Amazon Web Services Account menu

Next up is grabbing the EC2 Command Line Tools, which are a set of shell scripts written in Java and available for Windows or Mac OS X/Linux/Unix. You can get them from the EC2 Resource Center at http://tinyurl.com/2erefx. Once you have them installed on your machine, you’ll need to configure the EC2_HOME environment variable and will probably want to add the bin directory to your path. You can also make your life a whole lot easier by setting up the EC2_PRIVATE_KEY and EC2_CERT variables, which should point to the two files you stashed in your .ec2 directory, so that you don’t have to provide paths to them with every EC2 call you make. The instructions for doing so vary considerably depending on the operating system, so either consult your documentation or do a Google search.

You’re all ready to fire up your first EC2 instance! Your path will deviate considerably from this point depending on what you’re looking to accomplish, so I’m going to end this recipe here and point you to some resources that can take you further along in this process:

Amazon EC2 Getting Started Guide

http://docs.amazonwebservices.com/AWSEC2/2007-03-01/GettingStartedGuide/

Hosting Facebook Applications

Return Main Page Previous Page Next Page

®Online Book Reader