Friday, November 21, 2008

Tutorial on hosting a RoR (Ruby on Rails) application on Amazon AWS with EC2 and EBS.

We built a tourism portal in RoR for one of our clients. You can have a look at it - - www.tripladder.com
After building it, we were requested to host and manage it for them. Initially we went with knownhost which is OK but a production RoR application needs more RAM than what we get on most VPS plans - especially if we have image processing. We did consider AWS but at that time it did not have EBS and the client did not initially expect enough traffic to justify a 'scalr' managed cluster. We were looking for a replacement to a dedicated server. Once EBS was launched, we immediately decided to move the site to AWS. The Cost-benefit analysis is compelling.

The following tutorial starts off after signing up with AWS and configuring your desktop/laptop to be able to connect to AWS and launch instances i.e. we assume that you have completed the 'Getting Started' section of AWS.

We have started with the stock Fedora image and modified it to our requirements. We could have used CentOS but Fedora-8 appeared at the top of the list and we went ahead with it.

The application hosting has the following steps.
  1. Launching an instance.
  2. Installing RoR, gems, plugins...We used rmagick, hence we had to install Imagemagick too.
  3. Installing mysql.
  4. Intalling the application (checkout from subversion).
  5. Creating and attaching a EBS volume. Mysql with data on EBS
  6. Modifying the RoR app to save user upload files to EBS.
  7. Installing and configuring a production level ferret server
  8. Installing and configuring mongrel cluster.
  9. Configuring Apache to proxy to mongrel cluster, caching optimisations for performance.
  10. Configuring permanent public IP (covered) and DNS (we have the domain parked with go daddy but this is not covered in this article)
  11. Configuring smtp (email) support for RoR application.
  12. Once we have the perfect server setup, save it to S3.
  13. Periodic automated backups -This is available here: http://docs.google.com/Doc?id=dcn2ckbh_21gznbbjhr

For the full tutorial - go to this link.

http://docs.google.com/Doc?id=dcn2ckbh_20hk4kc4d4

1 comment:

1 said...

As you may know, standard template “Amazon EC2 Rails-All-in-one-trial” by Amazon AWS is not good… yeap, it is. Let me show you how fix it by your hads :)

http://railsgeek.com/2009/1/29/amazon-aws-ec2-rails-all-in-one