Deploy Rails 3.x app to Amazon EC2 - ruby-on-rails

I am using Heroku as a staging / testing server. For production, I plan to deploy to EC2, initially on 1 instance but the deployment should scale to multiple instances when needed. A quick search shows that there are web tools like Rubber and Chef which are designed for multi-EC2 instances deployment. But they do not look easy to grasp - atleast on first look.
I also see a simple guide here:
http://boredwookie.net/index.php/blog/ruby-on-rails-3-passenger-mysql-on-amazon-ec2/
which looks more easy to follow. But I'm not sure how easy or hard it would be to scale up to multiple servers if needed later if I follow these steps.
Any guidance in this direction is much appreciated.

Have a look at the Ruby Bitnami stack.
http://bitnami.org/stack/rubystack
There is a AMI, installs very quick in EC2. Without to much fuzz. When it comes to scaling i don't know, but i guess its a good starting point.

Related

Rails - Best deployment setup with AWS Auto Scaling

I am researching ways to deploy a ruby application to an AWS Autoscaling Group and I'm having a hard time deciding which way is best and finding good content about it.
I have looked into CodeDeploy, Elastic Beanstalk, CloudFormation, Capistrano, Chef and some others. The combination of some of them.
I, personally, didn't want to use Chef or anything that needs much time maintaining. Currently I am using Dokku on EC2, but I need to make a more scalable and elastic solution for a new project.
What would be the best suggestion and study material?
CloudFormation + ElasticBeanstalk works great.

References for web application scalability and deployment best practices

I find it easy to find resources on amazon/online to learn new frameworks/programming languages. However, when it comes to web app deployment, I find it really hard to find a single resource that explains all. Most of them just tell you what to do without explaining 'why'.
I just did my second rails app deployment with unicorn and nginx. Although I 'kind of' know what is going on when reading the tutorial, I would like to know more about the 'how' and 'why' of the steps that were given.
In short, I would like to read books/articles/tutorials (hopefully all-in-one) about best practices for web app deployment, and how to scale/load-balance your app when it gets more traffic (and hopefully it the tutorial uses NGINX/unicorn setup).
Well, deployment and scaling are completely orthogonal topics, so I don't think you'll find an article/tutorial that covers both.
As for deployment, you better automate your work. When you deploy to 100+ servers, the last thing you want to do is to do it manually (fetch from git, migrate db, restart servers, etc).
Capistrano - very well known and adopted tool for deploying Rails.
Vlad - another tool that gains more attention lately.
Chef - very powerful tool for server management. Several top Russian sites use it.

Pre-configured Rails VPS hosting?

Can anyone recommend a Rails VPS host that offers everything pre-configured (like Heroku) and just let's you upload and run your app? Heroku becomes expensive really quick as you scale up.
If you want a VPS that is pre-configured, you can try something like these
http://www.turnkeylinux.org/rails
http://bitnami.org/stack/rubystack
and then uploaded it to a VPS provider. I would recommend Linode.
Any service will become expense as you scale up - if you want cheap the likes of Slicehost, Brightbox (UK) offer vanilla VPS boxes but you're going to be setting stuff up yourself and sacrificing scaling. Maybe have a look at dotcloud.com - little more reasonably priced TBH than heroku
If you're looking for cheap hosting then a vanilla vps is very easy to set up. Check out the tutorials at http://articles.slicehost.com/. It's a really satisfying experience and good to know if you're a developer.
I read a lot that heroku is expensive but one free dyno plus a shared db at $15 will serve a lot of pages. Utilising varnish more so.
Depends exactly on what you want. Heroku is a great Platform as a Service offering. This means that they take care of administering the database, app server, etc. In turn, they are a bit more expensive as you scale and have restrictions on what you can and cannot run (to make it possible for them in turn to scale their operations)
If what you are looking is your own VPS, but with everything already setup, you can use BitNami (as pointed out in another answer by #Dex). We recently released BitNami Cloud Hosting, which has a free tier and together with AWS free offering allows you to have a Ruby On Rails environment running on a small machine (600 Mb of RAM, 10Gb disk) completely for free. If you need to scale, then you need to pay for Amazon charges, etc. This is great for starting out. Check it out!

What are the most common ways to deploy rails apps

I use Heroku to host and deploy a lot of little apps, in the past I remember ftp'ing and then Capistrano came around and made things a lot better.
Is Capistrano still the default deployment method or are there up and coming techniques or existing methods to deploy rails apps.
Capistrano is still at the state of the art, generally used with github.
Of course the easiest way to host your apps is Heroku if don't have your own server.
+1 on the other Heroku and Capistrano answers.
Outside of that, I'm particularly looking forward to seeing what VMWare's CloudFoundry has in store for us. One step deploys (and upgrades) very similar to Heroku, and you can actually host your own clouds if you want to. It's still in beta, but looks pretty slick from what I've been following of it. Supports Ruby (Rails, Sinatra, et al), Node, Java, and others.

Should I be using Chef or other tool for managing servers

I have 4 servers behind a load balancer and a staging server, a db server, and a utility server for a web application that hosts a number of web sites.
Should I make the jump to Chef to manage these servers or should I just maintain them manually? The servers were built using sprinkle but at that time there were only two. Now that there are four maintenance is becoming more of an issue.
I'd like to hear experiences and the pros and cons of chef and other chef-like tools.
Thanks!
We moved to Chef, and we now have a 1 minute redeployment for our app. So it certainly pays off.
However it took a long time (a few months) to get to the point where we were happy with the chef deployment strategy. With hindsight we would have had several spare boxes around to try out a 'from scratch' deployment. I certainly wouldn't advise trying chef in a production environment without an exact mirror of the setup and lots and lots of tests, nor would I advise using chef on a setup that hasn't been 'cheffed' from scratch.
Having said that, Chef is far better than the other options we looked at and now that we are out the other side it's a breeze deploying a new version of the app on multiple servers. In future I'll be using it for any staging or production environment I have.
In summary, yes, but only if your client/employer is aware that it may take some time before they see the benefits, which will be considerable.
Chef has a steep learning curve, so it will take a while - at least a few weeks - to become familiar with how to use it.
But once you pick up the basics, it is a very handy system, and can simplify any number of tasks - even for the smallest of infrastructures.
A few notes for when you start.
You will be setting up and tearing down cloud servers dozens of times, just to get the hang of it. Experiment.
The standard opscode cookbooks (github.com/opscode/cookbooks) are very useful. But you will need to extend/customize many of them for your particular case. And you will need to search the 'net for cookbooks that are missing from the opscode/cookbooks repository.
Read the opscode cookbooks, and read the 37signals cookbooks too.
The application and database cookbooks are geared towards standard Rails apps with MySQL and Memcached. To the extent that this describes you, you are way in luck.

Resources