Run a Google-scale Web Site with Amazon EC2
Published October 20th, 2006 in Technology.
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale computing easier for developers. It is tightly coupled with Amazon Simple Storage Service (Amazon S3) that enables storage in the cloud. Amazon EC2 is under limited beta right now with the limitation of 20 running instances.
At first look, the new service is easily confused with traditional web/application hosting services. However, the key difference is the elasticity of capacity. Traditional hosting service has various plans for different hosting capacity. As the demand grows, you will always face the problem of migrating to higher capacity hosting. Amazon EC2 claims to solve the problem by offering elastic capacity hosting.
Amazon EC2 enables you to increase or decrease capacity within minutes, not hours or days. You can commission one, hundreds or even thousands of server instances simultaneously. Of course, because this is all controlled with web service APIs, your application can automatically scale itself up and down depending on its needs.
You will be charged for CPU (@$0.10 per hour per instance), network bandwidth ($0.20 per GB) and storage usage ($0.15 per GB per month). You pay only for what you use as opposed to monthly charge. Amazon EC2 currently supports only Linux-based systems environments.
Another significant benefit as compared to traditional web/application hosting is full control over the compute resources. Using Amazon EC2, you can choose not only to initiate or shut down instances at any time, you can completely customize the configuration of your instances to suit your needs - and change it at any time. You even have an option of using SOAP API to control your instance. Most hosting services cater more towards groups of users with similar system requirements, and so offer limited ability to change these.
The following are the steps to “boot” a public AMI to start modifying it to your needs as described in the Developer Guide.
- Install Java Runtime Environment on your PC
- Sign up for Amazon S3 - If you don’t already have an Amazon Web Services Account, you will be prompted to create one as part of the sign up process.
- Sign up for Amazon EC2
- Create new X.509 Certificate to generate a PEM encoded signed X.509 certificate (cert-*.pem) and an unencrypted, PEM encoded RSA private key that corresponds to the X.509 certificate (pk-*.pem)
- Save the certificate and private key
- Lookup AWS account ID as EC2 user ID e.g. if the Account Number is 4952-1993-3132, the EC2 user ID will be 495219933132
- Download and unzip Command-Line Tools
- Set EC2_HOME to unzip path
- Set EC2_PRIVATE_KEY to private key file (pk-*.pem)
- Set EC2_CERT to X509 certificate (cert-*.pem)
- Find a suitable Amazon Machine Image (AMI).
ami-61a54008is the AMI ID for the image.
# ec2-describe-images
IMAGE ami-61a54008 ec2-public-images/getting-started.manifest 475219833042 available public
The command lists both public and private images that you have registered. Public images start with ec2-public-images - Generate keypair if running a public image
# ec2-add-keypair gsg-keypair - Save keypair in a file with the name
id_rsa-gsg-keypair - Set permission to only readable by you.
# chmod 600 id_rsa-gsg-keypair - Run the instance of the public image (Note: You will be billed per hour for CPU time at this point)
# ec2-run-instances ami-61a54008 -k gsg-keypair
INSTANCE i-10a64379 ami-61a54008 pending gsg-keypair - Check out the instance status. The Instance ID is
i-10a64379with a DNS namedomU-12-34-31-00-00-05.usma1.compute.amazonaws.comrunning indefaultgroup.
# ec2-describe-instances i-10a64379
RESERVATION r-fea54097 495219933132
INSTANCE i-10a64379 ami-61a54008 domU-12-34-31-00-00-05.usma1.compute.amazonaws.com running gsg-keypair - Authorize access to your instance e.g. SSH
# ec2-authorize default -p 22
PERMISSION default ALLOWS tcp 22 22 FROM CIDR 0.0.0.0/0 - Connect to your instance via SSH
# ssh -i id_rsa-gsg-keypair root@domU-12-34-31-00-00-05.usma1.compute.amazonaws.com - Terminate the instance as soon as you do not use it (Note: You will be billed as long as the instance is running which consumes CPU time)
# ec2-terminate-instances i-10a64379


1 Response to “Run a Google-scale Web Site with Amazon EC2”
Please Wait
Leave a Reply