Hosting Rails Web Application on Amazon EC2

I have my Ruby on Rails application running on EC2.

EC2 is a web service that helps in elastic computation across the web. It is elastic because the computation is very resizable. When compared with Plain Hosting it provides the following advantages:

The usage of the EC2 image becomes easier if ruby on rails application is to be hosted. As rails provide gems for additional utilities, it provides a gem called as “ec2onrails” that makes the hosting even simpler.

The following are the steps in using the EC2 image:

We now have our application hosted on EC2. Yes, it is that easy.

The only question that one would have in his/her mind now is, what will happen if my instance or the ec2 server terminates? Once the server terminates, the instance is lost and can never be got back. This is one feature that ec2 lacks. But it provides a solution to handle such situation.

There is something called as bundling of the image. On bundling the image, the instance configuration and the application is uploaded to the S3 which can then be register to another instance and the application can be in form again. This can be achieved as follows:

Prepare for bundling – The server requires the two privacy enhanced mail security files. This can be got by using scp command.

Example – scp pk-xxyyzz.pem cert-xxyyzz.pem root@ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com:/mnt -i keypair_file_name

Bundle the current image – From the ec2 instance bundle the image.

Example – ec2-bundle-vol -d /mnt -k /mnt/pk-xxyyzz.pem -c /mnt/cert-xxyyzz.pem -u account_number -r i386

Upload the AMI – The AMI is then uploaded to S3.

Example – ec2-upload-bundle -b bucket_name -m /mnt/image.manifest.xml -a access_key_id -s secret_access_key

Register the Uploaded image – The image needs to be register from the local system and can be done as: ec2-register bucket_name/image.manifest.xml

This gives an ami ID with which the instance can be run.

EC2 – a quick and cost effective way of hosting Web Applications.

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

Hi,

I am a Novoice Rails Programmer. I am finding a Host for my first application. I am looking forward to book accound on Amazon. But i am confused about the types of service and costing. Can you help me on this.

In EC2 there are two different category of instances, standard instances and high-cpu instances.

Under standard there is :
- small instance($0.10) This is the default one with 1.7 GB of memory, 160 GB of instance storage, 32-bit platform.
- large instance($0.40) 7.5 GB of memory, 850 GB of instance storage, 64-bit platform
- extra large instance($0.80) 15 GB of memory, 1690 GB of instance storage, 64-bit platform

Under high CPU instances, there are:
- medium instance($0.20) 1.7 GB of memory, 350 GB of instance storage, 32-bit platform
- extra large($0.80) 7 GB of memory, 1690 GB of instance storage, 64-bit platform

The pricing will be based the instance consumed per hour.

Hello,

Can you host my rails application on amazon? If you can please send me more information about prices. Thank you.

Leave a comment

(required)

(required)