Deploying rails: What to choose? - ruby-on-rails

I have just finished a Rails-application that I now want to upload to the web. It is a re-write of an existing application and I expect some 4 000 visitors a day with peaks to 10 000 a day at times.
I know Windows fairly well (have not used Windows server though).
I hardly know anything about Ubuntu or Linux
I want things nice and easy and don't want to spend too much of my time "hacking the server". I want to spend my time developing, not maintaining.
My budget is ~50$ a month at most for this project.
The database for the project is quite static (hardly any user generated data)
I am currently using WAMP & Mysql with Rails 3.0.3 on my local installation and it works fine most of the time but crashes quite often as well.
I am considering three ways of doing that:
Using Heroku
Seems quite easy (even though I haven't gotten it to work yet)
Also seems expensive, if I need more nodes. How many nodes should I expect to need?
Using a VPS Windows server
I know Windows and it would be fairly easy to install and get it set up
My friend (who is more of a Rails expert) says that Windows and Rails is not a good match.
My crashes on my local environment makes me nervous about this option
Using a VPS Ubuntu server
Seems to be the cheapest option (in terms of paying up-front)
Seems to be the most stable option
I don't know Ubuntu and I am not too eager to learn a whole new OS to get this set up.
Could you help me with directions? Is Windows server really bad for Rails?

Quite honestly, I think Windows would be the worst choice for you. The problem with Windows and Rails is that most of the gems are never designed to work with Windows, or the versions that do work with Windows are far outdated.
Using an Ubuntu VPS is a very viable option, would be your cheapest and most stable option. We use Amazon S3 services to run most of our web servers in the cloud. Like you said, it does require you to know and understand a *nix operating system to maintain.
Maybe for you, Heroku may be the best option. Heroku is super simple to setup your project on and then deploy. There are also pages of documentation to help you along the way. In a few basic commands from the terminal, your application is running. I often use Heroku as a 'staging' server to test application updates among beta users before pushing to production on S3. You also are not required to learn a new operating system to use it.
If you are running into problems with deploying to Heroku, please post the issues and we will gladly help you.

I would advise against a windows server. From my experience, the major ruby implementations are not optimized for windows - and run slowly. For the sake of your end-users, a rails stack on Linux may provide significant performance gains (or equally decrease your server budget).
With bundler and rails 3, the amount of maintenance work on the server should be minimal. Log in, deploy, log out. (look into tools like capistrano to make this even more straightforward).

By far the easiest production I've found so far is an Ubuntu server.
On Windows Rails tends to be slower and it's far simpler to setup something like passenger on *nix. If help is needed, there are more tutorials available.
My fastest setups have been Ubuntu Server and nginx.
PS. Rails 3.0 has gone beyond 3.0.3 so think about testing the latest version 8)

Heroku is delightfully easy to deploy to. If your database load is light, you can just use their shared 20GB PostgreSQL database ($15/mo). 2 dynos will cost you ($35/mo) so there's your $50 there. 2 should be fine to handle that traffic, and you can always scale during your high traffic times. Definitely would recommend adding the memcached add-on and utilize that as well. Install the New Relic add-on and you can analyze your traffic/load and scale accordingly.

I'd heavily advise against using Windows for a rails app deployment. Some gems compile slower on Windows, and some don't work at all.
I've worked with Heroku, but there are some complications with writing files to the Heroku instance as Heroku does not allow for local file writing. When working with Heroku, people usually offload write operations like file-upload to an Amazon S3 instance or Fog. In general, Heroku is really easy to deploy to, but when configuration comes along...it may be a bit more complicated than a VPS.
The best solution for me would be to go via VPS using Ubuntu. There's been a lot of documentation done on this, and you have more options with your configurations. In actuality, it's not so much different from setting up Ruby on Rails on a local Ubuntu development machine. If you need tips on how to deploy on Ubuntu, I've just recently written a guide on how to do so.
http://www.francisbautista.com/deploying-ruby-on-rails-apps-on-a-vps-nginx-passenger-capistrano/

Related

Ruby on Rails web server

I'm new to web development, and have a question about deploy ruby on rails application.
For what i'm understanding, there are two ways to deploy. One is using cloud server like Heroku (I'm currently using). You just need to upload your project to their cloud server and ready to go.
Another way is build your own server using, for example, apache+passenger. By doing this way, I need to have a physical computer with Ubuntu + Apache + Passenger running continually right?
So my question is which way is better, faster?
Heroku has a form of automated deployment built-in. There are other cloud-based providers which offer a similar sort of service.
The alternative is self-hosted. You don't need a "physical computer", you can use a virtualized server in the cloud just the same. Popular choices are Linode, Digital Ocean and Amazon EC2 which is what Heroku is based on.
"Better" is highly subjective. Do you know how to maintain a server? If the answer to this question is "No", then Heroku is probably the best bet.
If you do know how to maintain a server, you can usually get better performance from your own rig since you have full control over how your application is launched, how long it stays running, and can increase resources at marginal additional cost. The downside is you're responsible for everything should it malfunction.

Rails Deployment 101

I am about to deploy my 1st Rails app. I am stuck as I don't know what exactly I need to do. I know about Heroku, AWS, Capistrano and the like, but don't know exactly what they do, and what their benefits are.
I kinda know some things, but all are blurry and ambiguous since I have no formal training and learn as I go. So basically I need someone to explain the general anatomy of Rails deployment.
Something like: 'To make any app working on the web you need the following components... Ways to make this component work with Rails are following. Alternatives are these. These are pros and cons.' Not into too much detail, but general and comprehensive 101 guide.
The reason you may be confused is that there are a number of ways to do it. :D
Heroku provides one of the easiest solutions for basic deployments. You don't need capistrano, just git. (they provide a toolset to assist). Just git push heroku master. Also nice is that a simple deployment on heroku is free; you can pay for more power when you actually need it.
But if you need a little extra functionality that heroku can't provide, you have to host elsewhere, such as a private virtual host.
Capistrano is a set of recipes that help build a deployment environment, sort of like rake tasks. It does so in a very organized manner and allows for easy rollbacks. You define the hosts, their roles, and then the recipes use ssh and scp to set up the evironment. (the server also has to be ready to accept rails applications, through something like passenger)
The Rails and Ruby World(s) are pretty noisy, so I understand your confusion.
At the end of the day, you need your rails app on a server.
Now, even the term server can be a little confusing, because it is generally associated with
A remote machine
A program handling HTTP requests.
(for example webrick or thin which you start when you are developing on your computer and type rails s)
In your case you actually want a remote computer (hooked up to the net) which is running a program called a server to process HTTP requests and forward these to your app which in turn produces a request...
Heroku will help you out with that. (However Heroku adds several layers of abstraction to the mix. So it is not like you have one computer sitting somewhere in the heroku office, serving your application.) Heroku is dead simple to setup with git and rails.
And in the end all that is need to get your app to the "remote server" is a simple git push.
Read the beginner articles on https://devcenter.heroku.com/
I would also suggest for now: Forget about Capistrano.
Oh and you can think of AWS (or probably S3) as some sort of external hard drive, which your app can use to store larger pieces of data (like images, videos etc.)
I have a deployment guide with a good shell script which support Nginx + RVM + Unicorn: deploy_rails

Is there a Ruby on Rails host that supports FTP?

I'd like to create a development integration server that's on the open internet, running a Ruby on Rails app. But I need FTP or SFTP access to this server, so I can upload files to the codebase via FTP.
Is there a good Rails host that allows FTP connections? The cloud providers like Heroku and Dotcloud just support pushing from source code or build files, it appears.
Thanks!
If you have experience setting up a Linux box I'd suggest using a VPS service, like Linode (www.linode.com) for instance, that way you can pretty much have any service running that you want. And if you don't have experience, that's a great way to learn ;)
If it's just for development, Dreamhost's shared hosting works well enough and is affordable. $8.95/month for unlimited domains and storage and bandwidth and it supports Rails via passenger/modruby. You get ssh and sftp access and you can schedule cron jobs too. Especially great for development since you can easily create and destroy apps and subdomains. Main downside is that you'll face a tough time if you need any custom gems or if you need a different version of ruby from what your host's passenger is using. Customer service is good though, and they can install custom gems or move you around between shared hosts if need be. I probably wouldn't dare to deploy a live Rails site on their (or anybody else's) shared plan though.
All that said, lately I've moved to Heroku for dev/staging instances. Not worrying about custom gems is a big plus, and since we deploy live on Heroku it's nice to have almost the exact same environment in staging as well as live. Heroku is free for single-dyno apps as long as you don't spend too much time in the heroku console. Pushing code from different branches to different instances becomes a piece of cake when you use heroku-san.

Selecting a Rails host [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm close to picking a Rails host. I think I need a VPS solution, because (1) my Rails app has gems and plugins that I need to install to get it working, and (2) I need an SMTP server to send emails from my rails app out to users.
But then it occured to today...
1) Do I actually need VPS and root access to get my app up and running, just because I need to install gems, or can I just copy my Rails app folder up to a Rails-supporting hosting server and start it?
2) If I get a Google Apps account, which would include a business-class GMail solution, would that give me an SMTP server which I could use to send emails to users?
I'm looking for least-support-needed-solution. I can afford to pay for VPS hosting, and a Google Apps account, but I just wonder if this is really my best option.
UPDATE: It's now been just over three years since I first posted this question and answer. I still prefer AWS for all new deployments of a professional or serious horsepower nature (that is, if I don't self-host), but I also regularly deploy demo and tutorial apps to Heroku. I haven't tried any of the many VPS providers that have popped up such as Linode or DigitalOcean, but generally hear good things about them.
The key thing that keeps me from choosing Heroku for all my apps is cost. Since most of my indie projects outside of work are things where I'd prefer to absolutely minimize costs, AWS remains the better deal between AWS vs. Heroku. AWS (or any VPS provider for that matter) has the nice side effect of teaching you the OS along the way, which turns out to be hugely valuable in the long term.
=======================
So, two years later, here's my update. I've used three services for hosting, and here's my take on each of them (I actually love them all, but for various reasons).
Slicehost (now part of Rackspace Cloud Hosting)
This was the first VPS host I tried, and I loved them. The people there were amazing, support was awesome, and it had a really cool grassroots kind of feel. Now that VPS as a solution is more mainstream, and Rackspace has long since purchased Slicehost, I feel that the service offering is still awesome. If you want a simple way to setup a server, plenty of Linux distro choices, and control over your server, this is an awesome option.
Heroku
Love these guys too. I built a hobby app that is hosted there, rpglogger.com (which as of Nov. 2012 has actually migrated to Amazon Web Services), and developing and deploying to Heroku is a no-brainer. I really like working on Heroku for two reasons:
It's dead simple to setup. It really is as easy as they say, in my experience, to get an app running on their platform.
A single dyno (web server instance) is free. So hobby apps, and smaller apps basically get free hosting. It's not just for hobbies though - their plugin architecture is second-to-none, making the addition of 3rd party plugins such as NewRelic, Exceptional, and anything else on their platform a matter of just a few clicks.
You absolutely cannot beat Heroku for ease of use. Deploying an updated version of your app is literally as simple as pushing to your git repo. Heroku isn't necessarily cheap (for anything other than the small app), but if you're in a situation where you believe developer time is more valuable than having control over the server, then this is an amazing option. You can always migrate your app to any other platform anyhow, if it gets big, or the needs of the app vs. the cost of Heroku no longer make sense for you.
Amazon Web Services
I do quite a few small apps, and AWS reserved instances are awesome. For $60 I can basically get a reserved instance for an entire year. That one server is enough to run 3-4 small apps on the same machine, with more optimized memory usage, and the ability to run multiple web server instances (vs. Heroku's one free dyno, though I hear you can custom config your Heroku dyno using unicorn to get more scalability). Basically, AWS scales really well, and lets you share a server among multiple small apps, or spread a larger app across multiple servers.
On top of that initial cost for the reserved instance, I only have to pay for bandwidth and other AWS usage (S3, for example). I think AWS is an amazing mix of ultimate scalability, great costs, ultimate control, and for enterprise customers who want to build their entire infrastructure in the sky, it can't be beat. Rackspace Cloud Hosting provides similar services, and they're probably comparable for most things. But if what you want is the Swiss army knife of cloud services, I think AWS is still way ahead of everyone else.
===============
So, that being said, I started on Slicehost, then went to AWS, then tried Heroku, and today I spend most of my time back on AWS.
AWS is the kind of platform that, after you invest a little time in setting up your collection of VPS machines, it often makes sense to stay on this platform and leverage their ever increasing set of tools.
Granted, it took me two years of trying several options, and trying every level of management from fully managed servers (i.e. Heroku, where you don't even think of the server, just the app) to fully controlled servers (Slicehost and AWS). After all that I've come to this point where I'm ready to manage my own machines in order to get the flexibility and low costs that I want.
Through automation, the actual management of the servers on AWS becomes a non-event, so I don't spend my time constantly patching my machines, or doing other sysadmin tasks. I just check periodically to see if my servers need reboots, I set them to automatically install all security updates (I happen to deploy to Ubuntu servers), which means I spend 99% of my time (at least day-to-day) writing the application - not managing the servers (managing services is instead an occasional task of a few day's work, and then nothing else for months) - which is where I want to spend my time as a developer.
Neither of your requirements are VPS-specific. I use shared hosting from Site5 and currently run two rails apps through the account, both with gems that are not installed on the server by default and sending email. Installing gems does not require root access.
If you want to use a VPS anyway, both Slicehost and Linode are often recommended for Rails apps. A few more are listed under Deploy on the Rails site. I would encourage you to do some research on your choice in either case. Good luck!
You could check out Ruby on Rails Hosting, What is a good Ruby on Rails hosting service?, Good Ruby on Rails free hosting, and What is a good Ruby on Rails and PHP hosting?.
I personally prefer Heroku which has offers free low-scale hosting and is very easily upgraded. Also, they allow you to install gems (similarly to the gem dependencies and rake gems:install, but with different syntax/files), and send a few free emails (200, but it is easily upgraded).
I hate Heroku, it gives you no control over services you want to use and it's massively over priced. Just try to make use of a gem or service they don't specifically support and you will quickly find the limitations and the horrendous pricing.
Heroku is my host of choice.
You can send messages using GMail SMTP as well as the commercial SMTP plugin.
I have also used Slicehost, Linode, Dreamhost and RailsMachine.
Slicehost/Linode are awesome if you can set up the box yourself.
Dreamhost is cheap-as and great for staging. Sites are ponderously slow at times though.
RailsMachine is second to none as a managed service. Highly recommended for the support and the well-tuned stack.
I prefer linode, aws or so.
linode : is a standard linux server. you can login, install 3rd party dependencies and play around just like in your own server. Installing nginx/rails/ruby is the same way as what you did on your own pc/laptop/server.
heroku : is a service. I have to learn lots of stuffs that are not valuable at all if one day you switch to another platform(e.g. linode) or you have your own real server, for example, check the logs, install databases, or install gems. I have printed out most of its documents and read them in 1/2 days, and then I realize that I can't use these knowledges in my working server( that my company offered to me)
linode is cheap enough, $20 per month.
heroku is not always free. and I don't think it's stable enough for demonstration purpose.(e.g. your free heroku app will fall in sleep in spare time, and will cost you several seconds to wake up. this SEVERAL seconds is long enough to make you lost your customers if they want FAST web app )
so, forget heroku, buy or setup your own VPS, use it for years, then you will be an linux expert.
I use HawkHost for all my hosting needs, and I'm 90% sure they meet all your criteria. They provide web hosting and VPS services for very good prices, and their basic web host plan lets you have Rails applications running as well.
I'm used Joyent host- http://www.joyent.com. It's good Rails host.

Making ruby on rails take up less memory

I'm trying to run a Ruby on Rails project (redmine) on a VPS. It's working, but it takes quite a bit of RAM. The rails application has very light usage compared to the rest of the VPS. I have lighttpd running on the server as well.
I'm new to Ruby and know there are several ways to launch a webapp in Ruby. I'm currently just using webrick (and am okay with launching it by hand). Is there another way to launch a webapp that is more memory efficient?
Rails really just takes a shitload of memory, it's a damned big app. One of the things you can do is try to get Ruby Enterprise Edition installed but if you're on a VPS there's probably not much chance of that. But perhaps the best option is to drop the app on heroku and not worry about it anymore. You'll have other difficulties like setting up email to contend with but otherwise Heroku is the best thing that ever happened to rails (I think at least. Maybe Merb though :P)
If you're new to Rails, configurations, and even Linux - your best bet is Apache/Nginx + Phusion Passenger + REE. If your VPS is something you control such as Slicehost, Webbynode, Linode, or similar - then that'll be the easier route.
Slicehost articles should help you out a lot by walking you through each step of configuring your VPS. And the steps even work on other VPS hosting companies, just match up the Linux distro.
If you're really green to RoR and setting up VPSes's-es (?) and unless you need more than a 512MB slice - I agree with Chuck, start with Heroku until you hit about 3-4 dynos. And since the Redmine demo is on Heroku - you know it works!

Resources