After a bad experience trying to get even the simplest Rails application running at Lunarpages, I'm moving to Slicehost. Does anyone have an opinion as to which of their Linux distros to use for a fairly high-traffic Rails site? They offer CentOS, Debian 5, Fedora (10 to 12), Gentoo, Red Hat EL 5, and Ubuntu (8 and 9).
While we're on the subject, does anyone have any opinions as to the relative merits of Slicehost versus Amazon WS?
Thanks!
I've always been a fan of Ubuntu, it's easy to use and lots of other people are using it so there is a lot of information if you run into trouble.
I've never used Slicehost but AWS is pretty great if you're going to be bringing instances up and down often (since you only pay for what is running). If you just have one server that will be running continuously then AWS might end up costing more without giving you much benefit. It all depends on how you use it though and if the flexibility of AWS is worth the (potential) added cost in your situation.
If you are interested in systems administration. I would go with Slicehost, Linode or AWS ec2, Linode has been shown to be more performant (link) than both Slicehost and AWS.
With that said, if you aren't interested in systems administration I would go with Heroku. It is the easiest way to deploy and management is minimal. You do have to be aware that Heroku is limited on some 3rd party services you would install on your own, but but they do have some packages included that you can enable for sending email etc. You are also limited on file size and they recommend you store your assets on AWS s3.
In terms of overhead Linode is less than AWS ec2, because AWS ec2 is really for high availability, Heroku is the least as mentioned above. AWS will cost you more than Slicehost or Linode and I think if your site is small more than Heroku too.
You will need decent Linux chops to get going on AWS, Slicehost, and Linode. Heroku will keep you away from most of this but also limit you if you need something really custom. For distro choice I would say Ubuntu hands down if you are new.
I've run RoR on Ubuntu 8.04 LTS on Amazon (Approx 3-4 years worth of uptime across a few servers for a couple of sites) and Slicehost (Approx 8 months). I've had zero complaints/niggles/problems with the linux distro or the hosts themselves. I'd just grab whatever linux distro you're most comfortable with, I build pretty much everything from source for RoR in production anyway:
Download gem
Build Ruby EE from source
Install passenger with nginx from source
etc. etc.
As to the merits of your two options, I've always used Amazon for work/business and slicehost for smaller stuff. This is pretty subjective and I really can't fault either, but for work/important stuff I'd still lean towards Amazon. It's not a strong leaning, but the flexibility of turning on/off instances at will, plus S3 would have me go that way again.
I'm using slicehost and running Ubuntu intrepid with passenger/rails.
My choice was mostly based on there being a lot of rails related documentation for that distro. Which has definitely made it easier.
http://articles.slicehost.com/ubuntu-intrepid
In terms of dedicated rails hosts, don't forget to check out heroku. They use a completely git-based system to deploy your app (which can be written against any of the major Ruby frameworks), and you only get charged for the database and CPU-hours that you actually use.
I also have heard good things about EngineYard.
Ubuntu is likely the most popular OS for Rails, probably because of Ubuntu being a very popular Linux distro. It's a great OS that will do anything and everything you need it to.
Having said that, it's not necessarily the only distro that works well with Rails. CentOS, for instance, is an excellent choice as well.
I would also second other people's recommendations of Heroku, and EngineYard as well. For VPS, I would probably rather pick Linode over Slicehost.
I'm partial to Ubuntu, as once you get your apt-get all updated and squared away, installation is quite quick and painless. Though, I'm sure this is said for any distro that makes good use of apt-get.
I second (or whatever sequence this shows up as) the calls for Heroku and Linode.
As for Amazon, I use the S3, and RDS if I can. The RDS not as much, but I'm moving some stuff there. But paperclip with the S3 is pretty great.
I use Centos for development and production, not problem with that, I think you need check some specific needed points in your app and only important stuff.
A GNU/Linux distribution with required points (or maybe that allow to put in) is all that your need, for example begin from a kernel.
Related
I must configure my RoR vps hosting for my rails app, but on my localmachine i simple use webrick...
Are any ways to do this on server, so that it will be faster, and also, if it reboot's or memory down, or something that call's shutdown of server, then it automatically starts?
Also how about rails enterprise?
Now i have clean ubuntu server, and rvm on it
Follow this tutorial, it's great for beginner and will answer all your questions: http://coding.smashingmagazine.com/2011/06/28/setup-a-ubuntu-vps-for-hosting-ruby-on-rails-applications-2/
Which webserver to use depends on many things. Among others, there's Thin, Unicorn, Rainbows, Puma, and counting.
I suggest you look on google (or even here, I'm pretty this was answered before) for comparisons between ruby webservers, so that you can know what situation each of them are adapted to, and which one will fit your needs best.
For production deployment you need to install nginx or apache,
nginx is lightweight ,consider installing nginx,
Now there are various ways simple and easy to install is passenger with nginx
Or simply you can use nginx+unicorn or nginx+thin you can find various article just google it.
Would some of the more advanced rails developers please share what they have found to be the most productive combination of OS, IDE, etc. (i.e. the set-up that gives the least of amount of compatibility issues, headaches)? Also, what is the most commonly used setup?
I presume the common setup is common because it is thought to be the best compromise between all the options.
And that common setup is:
Mac OS X
TextMate
rvm
There's a lot of nuance to your question, for example you'd probably want to take into account what you already have, what your appetite is for spending money, etc. This is before even coming to the minefield of personal preference. :)
Here's a starter list:
Operating System
In my experience on both, Mac > PC for Rails programming because it creates fewer unforeseen/annoying problems.
IDE
Depends on how 'rich' you like your environment to be. Some people who like light environments simply use Notepad++; others use richer options like TextMate (Mac only) or RubyMine.
General Set up
Rails 3.1, MySQL
Local Server
Webrick and Mongrel are fairly popular.
Hosting
Heroku is extremely popular for Rails apps. It's free for low traffic and they're beautifully designed for Rails. If you want to avoid the server reloading problem (webpages take a while to load if no one has requested them in a while), you can set up NewRelic or Pingdom to ping the app and keep it active.
Performance Monitoring
NewRelic
I moved from Windows for Rails 3 to a Ubuntu 11 virtual machine running on Windows via VMWare player.
I'm using Gedit along with GMate (source here) to make Gedit more similar to TextMate for Rails Development.
I've found the setup to be way faster running on the virtual machine than it was on Windows directly. It took some time to get set up but once done, I just transfer the vm image from machine to machine. The setup was all free too (besides my laptop and the copy of Windows 7 on it).
The most common development environment I suspect you'll find among the Rails illuminati is probably:
Mac OS X (though some use Linux)
various Ruby versions/gemsets in RVM
TextMate or MacVim as the IDE (gvim or vim for the Linux folk, usually, though some prefer Emacs)
SQLite or MySQL for development database
Webrick, Mongrel, Thin, or flavour-of-the-day lightweight local webserver
My setup: Rails 2.3.10, Ruby 1.8.7 on Windows
The last time I deployed a Rails app from Windows to Linux on Slicehost, I used Capistrano, Nginx, Mongrel, and SVN. That was 3 years ago, fast forward to now, I'm still on Windows for development and is now looking to deploy to EC2. A quick search turns up tools like Rubber and Chef which aren't easy to grasp with a quick read. It seems like Rubber and Chef are designed for multi-EC2 instances deployment which will be useful when I need to scale.
I'm also new to Passenger but it seems to be the default way to deploy Rails app nowadays, one thing that isn't so clear to me is whether Passenger is a replacement for Mongrel? In my old setup, I configured Nginx to forward the Rails requests to a cluster of Mongrel processes but I don't see anything like that for Passenger.
Any insights are much appreciated.
We use something like what you're describing for our production server: EC2 + Apache + Passenger. We haven't had any need to use the fancy deployment tools you describe - plain old Capistrano (plus capistrano-ext so we can use it for multiple environments) does the job just fine. I've looked at Rubber (not Chef), but deemed it needlessly automagical and too poorly documented, and I'm really not sure what it offers that can't be done just as well with roles in Capistrano.
Passenger has been great. It's an "overseer" that manages a collection of Mongrel-like workers (I had thought that the workers were Mongrels, but upon further reading, I don't think they are. The Passenger comparisons page even compares its RPS to a Mongrel cluster, so...), starting them up as needed, culling them under low loads, restarting them if they crash, etc. It's actually very similar to the Server + Mongrel Cluster you described, but probably a bit better, as Passenger has an understanding of the underlying workers that Nginx / Apache don't. And you'll have to make a few minor tweaks to get Capistrano playing nicely with Passenger.
And if possible, pair Passenger with Ruby Enterprise Edition (from the same guys who made Passenger). It's a much faster version of Ruby, mostly due to a rewritten, configurable garbage collector. You'll have to tune your GC settings to get the most out of it.
Hope this helps!
Both might help:
http://ginzametrics.com/deploy-rails-app-to-ec2-with-rubber.html
Hosting rails on ec2
Rubystack allows you to have the same Rails environment for development on Windows and for deployment on Linux. We also have EC2 images (scroll to the bottom) and it is completely free, so you may want to give it a try.
Also, this may not work for you, but depending on your requirements, you may want to go for a PaaS solution like Heroku
We really like the idea of hosting with Amazon EC2 and the excellent EC2 on Rails, but our cashflow isn't enough to justify a move to EC2. So we've decided to host with linode. Now we're trying to put together the best Rails server build.
For those that don't know, EC2 on Rails is an opinionated Ubuntu Linux Server image for Amazon's EC2 hosting service. Out of the box, it runs a standard Ruby on Rails application with little to no customization.
So, is there something like EC2 on Rails for linode?
We'd need at least the following:
Ruby 1.8.7
Ruby on Rails 2.3.8
MySQL 5
memcached
Automatically runs hourly, daily, weekly and monthly scripts if they exist in Rails application’s script directory
Local Postfix SMTP mail server
SSL support
Passenger + Ngnix or Mongrel + Apache
32 bit image Ubuntu
With a railsy setup, meaning fast and simple. So, anyone run across anything like EC2 on Rails, but for linode?
I have been using linode for my personal use for a while and I think no matter what, you are probably going to have to get your hands dirty. I kind of like it for exactly that reason, but that is just my taste. They do have stack scripts with some predefined setups. The closest I can find to what you are looking for is a ruby/apache/mysql script that is fairly customizable.
From the script:
Installs a fully functioning, ready to
go stack that's optimized specifically
for your Linode's resources. By
default, it creates a VirtualHost
using the reverse DNS of your Linode's
primary IP.
This installs a stack based on Ruby,
Apache, and MySQL. This also gives you
the options to install gems so that
you can be up and running Ruby on
Rails in no time.
Optionally creates a MySQL database
and user, and assigns that user grants
to the database.
You may use this as an example for
creating more VirtualHosts. Set up
VirtualHosts, install your sites,
point your domains to your Linode, and
you're set!
This script downloads and compiles the
source from Ruby's ftp. Along with
Ruby, the latest version of ruby gems
is installed and you have a choice of
initial gems to install. Rails and
passenger can be used to have a ready
to go Rails server. Once this script
has finished be sure to run
'passenger-install-apache2-module' to
complete the passenger install.
Note that this script may take 1.5 - 2
hrs depending on the gems that are
specified.
All details of this stack script are
logged to /root/log.txt and the stack
script is finish when the line
"StackScript Finished!" is written to
the log file.
You might have good luck talking to their support though, they might have some more secret sauce that I haven't found yet.
Nothing in that setup sounds EC2-specific beyond the name. It appears it is just convenient to use with EC2, because they let you grab a disk image from another account.
You are welcome to create your own StackScript to do this and contribute it to the community. Once a StackScript is written, it can be marked public and used by others. EC2 on Rails has a public GitHub repository from which you can get started, and honestly, I'd love to see things like this ported to the StackScript system.
Can anyone point me to an article with the best way to quickly setup a Slicehost slice with Rails/Git from scratch?
Slicehost has a number of useful articles on how to set up rails. These capistrano recipes might also come in handy.
If you arent' experienced linux/apache admin, you can follow a sequence of 6-8 of pickled onions posts: apt-get update, SSH, iptables, mysql, ruby, gems, rails, apache, mod_rails
Here's the sequence for ubuntu intrepid
Here's what i used for Hardy
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-1
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-2
http://articles.slicehost.com/2009/2/2/ubuntu-intrepid-installing-mysql-with-rails-and-php-options
http://articles.slicehost.com/2008/4/25/ubuntu-hardy-installing-apache-and-php5
http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-config-layout
http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-configuration-1
http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-configuration-2
http://articles.slicehost.com/2008/4/30/ubuntu-hardy-ruby-on-rails
(This is a good minimal sequence. I would recommend spending more time learning iptables, denyhosts, how to blacklist IP's and summarize logfiles to lock the server down).
I just did a slicehost installation (Ubuntu Hardy/RoR)
Install Ruby
thin installation (your RoR server)
Nginx installation (The web server/vhost/proxy)
Watch git tutorials here - they are great!
Thin/Nginx is very easy to set up compared to Apache/Mongrel, and uses less memory. Apache wins in some performance test, but uses more memory.
Rails core team member Josh Peek has some Capistrano recipes for setting up and deploying to Slicehost.