Thursday, August 03, 2006

Ruby on Rails (RoR) Deployment/Hosting could be a Pain

After recovering from my obsession to find my “Perfect” blogging software, today I fall into another obsession to find a “Perfect” web framework.

I have been following the buzz of Ruby on Rails (RoR) for quite a while, and recently had been getting my hands on a few tutorial and instant fallen in love with it. RoR is perceived to have high productivity gain, with an almost complete suite of web framework (Rails) and backing of a powerful and clean new age language (Ruby). It gave me quite a good impression, though I had not developed anything serious with it (neither had I master it), but I am planning my next project on it.

One major drawback of RoR is deployment. First of all, there aren’t many web hosting company out there support RoR, thus it won’t be as cheap or as common as PHP. Luckily my web hosting company is quite innovative and supported RoR few months back, thus it kinda motivate me to give it a spin.

I have no idea how to deploy a RoR application, thus I copy my entire application folder to the server and that didn’t work. Luckily the web hosting guys is quite helpful and gave me a shell account (more power, muahahaha).
  1. Login into my shell account, and go to my web folder
  2. run “rails app_name”, using the same name as my application
  3. Configure database in config/database.yml
  4. Replace the entire app folder
  5. Go to http://server/app_name/public and a Ruby page is shown (since my application is not properly configured yet)
  6. To test whether RoR is working or not, just go to one of the controller and test it out, such as http://server/app_name/public/recipe/list
I know, the above configuration is not secure and does not look elegant, but I just wanna make sure RoR can actually run on my server. But I found that RoR on standard CGI on Apache is really slow as compared to my PHP application on the same server. Thus I research a bit and found FastCGI, thus I tried to configure it but fail (return me with some 500 Server Internal Error). So, I am stuck and hopefully some handy technical support guy would be able to help me.

Upon further research, I found RoR is actually quite messy in terms of deployment and hosting. In order to have reasonable performance, they have
  • FastCGI - language independent, scalable, open extension to CGI that provides high performance without the limitations of server specific APIs
  • SCGI - a project to replace CGI and FastCGI with a simpler protocol to both implement and manage
  • Lighttpd - a fast web server that is very similar in speed to Apache 2.0 MPM-Worker on Linux
  • Mongrel - a fast HTTP library and server for Ruby that is intended for hosting Ruby web applications of any kind using plain HTTP rather than FastCGI or SCGI
This is actually bad news, with so many choices out there, each using different technology and approach, and no clear leader in sight. Frankly, they should have just continue with the approach of apache module such as FastCGI (or perhaps SCGI), where apache had a large install base and perform reasonably well. By introducing a new web server to compete with Apache will kinda dilute the market and create more branches, thus causing more massive confusing options in the market. It seems like supporting Apache is a reasonable way to do this, such as what PHP did. With more branches and technology options, it is gonna create havoc and confusion for RoR deployment.

At this moment, RoR deployment and hosting is not straightforward and neither well supported. RoR could be fast in development, but it might have drawbacks in performance and deployment/hosting.

As such is the life of bleeding-edge technology, there are bound to be lots of technical obstacles and non-standardization. Competition is good, but there is lots of casualty during the war. I still remember when I get my hands on PHP 5.0.0 and start coding on it, and yet couldn't find any cheap web hosting company which supports it. Thus I revert everything back to PHP4 which is well supported and supposing run faster.

There is a price to pay for bleeding-edge technology, go there only if you are well prepared.


Forgive me for my slight ignorance and lack of knowledge. It seems like Lighttpd and Mongrel can work together with Apache through its mod_proxy_balancer module. So, it depends how well your web hosting company configured RoR for you, or how difficult is it for you to configure the optimum setup for your box. Anyway, there seems to be a growing trend to ditch Apache and use Lighttpd instead, which might be bad news for market stability

Anything which worries me is RoR performance, it may be fast to develop, but it may not run fast. RoR with Apache + CGI is definitely is no no, as it crawls and abviously slow. I am not quite sure about Apache + FastCGI, it should be slightly better, but there seems to be better (and more complicated) options out there.

Framework Performance for Symfony on PHP, Rails on Ruby and Django on Python should be quite a good read.

1 comment:

rosi said... have provided very nice information about webhosting...nice job...keep it up