Web Frameworks vs. Hosted Environments
There’s a fascinating post on DreamHost blog about how frustrated they are with trying to make Ruby On Rails work for their bread-and-butter market of shared web hosting. I’ve run into this intermittently ever since I first tried out Rails two years ago. It’s fun to develop in, it works great on my local machine, but it’s been impossible to get any Rails app to run correctly on my DreamHost-ed web site. I’ve been told by experts that you pretty much have to step up to an expensive virtual-server solution (although I just heard about HostingRails.com, which is quite cheap.)
As already pointed out in comments, this issue is not specific to Rails, or to Ruby. The same problems apply to any complex web-app (including Python and Java ones, and probably some of the larger PHP-based frameworks too) that has a large amount of set-up overhead. By running a separate app process you amortize the setup costs across large numbers of requests.
This is a more complex model than a simple CGI or mod_whatever, but it’s a straighforward engineering problem and there’s no reason it shouldn’t be workable in a shared environment, without having to make every user rent their own server. I really hope this gets fixed — I was surprised to hear that it isn’t considered a big deal by the Rails dev community.
Updates:
- Rails founder David “DHH” Hansson just posted his view on The Deal With Shared Hosts, which sounds pretty reasonable to me (as an explanation of why shared hosting hasn’t been a priority for Rails, and an invitation for sites like DreamHost to help make it so.)
- Peter Cooper points out how this is hurting Rails adoption, and suggests fixing mod_ruby to work in a shared environment. (Also pointed out in the comments to my post.)
January 9th, 2008 at 9:47 PM
Rails’ sweet spot in when you can run relatively few apps per server, e.g. 37 signals has only a few apps, twitter is a single app that has its own fleet of servers, etc… The standard Rails deployment model, i.e. long running processes with lots of memory doesn’t jive well with many shared hosts, because, well, RAM and CPU are costly, and shared hosting accounts are cheap. Having dozens or even hundreds of Rails applications running on a server leaves both the servers and the applications running slowly. That causes the host to lose money, because they either alienate their customers because of the load on their servers, or they have to decrease the number of users per server.
(I am both a Dreamhost subscriber and a Rails developer, however, I avoid running any Rails applications on Dreamhost)
You mentioned that Python suffers the same fate. However, Python (including Django) can use mod_python.
January 9th, 2008 at 9:54 PM
Ooops! I missed the last paragraph of your post.
There exists an Apache module called mod_ruby, which works similarly to mod_python, mod_perl, or mod_php. The reason it is not used in production is because of the open nature of the Ruby language. In Ruby, one can open existing classes and change their behavior, even in the core classes. Because applications may freely modify the core classes (or any other classes, for that matter), and because the environment is long-lived, it opens up a Pandora’s box of security and compatibility problems. There have been some attempts to solve that problem though, and allow a Ruby process to be shared without having to share the execution environment. Google “ruby sandbox” for some examples. It certainly is a solvable problem, but unfortunately, the solution just hasn’t been created yet.
January 10th, 2008 at 1:55 AM
Web Frameworks Hosting…
I have to take the opportunity to plug WebFaction as a satisfied customer. They do hosting for all manner of dynamic languages, (including Python/PHP/Rails) Subversion, etc. Their latest service modifications to allow unlimited domains, websites, pro…
January 10th, 2008 at 11:32 AM
@John: Isn’t it possible to run multiple instances of the Ruby VM, with independent class tables, etc., in a single process? Or does Ruby use global state?
@Abundance: Thanks for the tip — I’ve just watched “WebFaction”:http://www.webfaction.com/ ‘s screencasts and their support for Rails and other app servers looks amazing. I’m very tempted to sign up.
January 10th, 2008 at 10:26 PM
Media Temple has Rails running in their grid containers, with some utilities to manage the lifecycle of each Rails “application” that you’ve set up in the container.
I couldn’t tell you exactly how it is implemented, but I know a container is a sort of a stripped down virtual machine (e.g. you have very little control over the environment or software it runs within, which is a good thing in terms of them managing security updates & so forth).
Essentially you get a guaranteed allocation of memory, CPU & bandwidth for your container, with all the Unix server configuration and processes hidden from your container. The only thing in your container that you can see is the actual Rails applications.
Engine Yard does something similar.
If they can pull it off, surely DreamHost can as well, or perhaps DreamHost doesn’t have the engineering resources to do it if it isn’t bog standard Apache style hosting - Who knows.
January 11th, 2008 at 8:08 PM
I’ve been involved in the Django community rather than Rails, but I’ve got to say that I’ve hard actually very good luck getting my web-app code up and running in shared environments. I’ve used WebFaction and TextDrive, and they were slightly different, but both pretty straightforward to make “work”.
There’s the usual problems with “you get what you pay for” - a $9.95/mo account isn’t going to nessecarily have amazing realibility (there was a month when I was ready to shoot TextDrive because the system reliability was so crappy) - but the functionality was all there. Since you focused on Rails, I’ll assume you’re headed more in that direction for your own interests, but if you’d like to talk specifics about setup and operation of Django based sites, I’d be more than happy to share with you.
January 13th, 2008 at 1:39 PM
There are a number of virtual private server VPS hosting providers where you can host most anything for around 20 bucks. I am using http://www.silverrack.com to host JavaScript apps on the server side using Helma. SliceHost (http://www.slicehost.com) is another option.
January 16th, 2008 at 8:18 AM
One word… WebObjects. Quick, run away!
January 25th, 2008 at 9:34 AM
WebObjects FTW!