Tuesday 30. of September 2008
Tags:Ruby as a scripting language, who is faster rails 1.2.6 or rails 2.0.2?, speedy rails server     By: By: Humayun Saahi
Posted in Enterprise 2.0, Ruby

Last time we compared the performance differences between Ruby and other languages. Let’s continue by dissecting what makes Ruby a good scripting language.

Ruby as a scripting language

To further explain let’s say Ruby is "an interpreted scripting language for quick and easy object-oriented programming" -- what does this mean?


Interpreted scripting language:

  • ability to make operating system calls directly
  • powerful string operations and regular expressions
  • immediate feedback during development

Quick and easy:

  • variable declarations are unnecessary
  • variables are not typed
  • syntax is simple and consistent
  • memory management is automatic

Object oriented programming:

  • everything is an object
  • classes, methods, inheritance, etc.
  • singleton methods
  • "mixin" functionality by module
  • iterators and closures

Also:

  • multiple precision integers
  • convenient exception processing
  • dynamic loading
  • threading support

While comparing to JAVA, if seen in perspective of real cost, scaling the cost of a Ruby app is on par with a similar Java app. The cost for hardware is the same when it comes to a Ruby on Rails web app and a big J2EE app. It might take less effort to setup Apache + mod_proxy + mongrel + Capistrano + memcached, than to go through JBOSS and Tomcat.

Speedy Rails server

Further Rails applications can be clustered quite easily to provide very powerful scalability with much less investment than typical applications using other languages. Here is an example of Mongrel, an open-source HTTP library and web server for Ruby written applications. It has the distinguishing feature of using plain HTTP rather than FastCGI or SCGI to communicate with other servers, which is widely believed to be faster than WEBrick (another Ruby library providing simple HTTP web server services).

Capistrano is another open-source tool, written in Ruby, which runs multiple servers and deploys web applications. It is used for automating tasks on different remote servers (one or more), executing commands in parallel on all targeted-machines and provides a mechanism for rolling back changes across multiple machines.


Unless you intend to get into the framework invention business, there is nothing comparable to Rails in either .NET or Java.


Who is faster Rails 1.2.6 OR Rails 2.0.2?

I would like to share an example (as it saved me from testing real time), which I am quoting from Hongli Lai's blog post, "Performance Comparison: Rails 1.2 vs 2.0". He has tried to clear out the misconception about Rails scalability by writing two dummy applications - one for Rails 1.2 and one for Rails 2.0. Hongli has been trying to prove that Rails 2.0 is faster then Rails 1.2. Without going into extreme details (regarding how this was done ) the results were:

Application ran on Mongrel:

Rails 1.2.6: 141.19 requests/sec

Rails 2.0.2: 214.76 requests/sec

Rails 2.0 is 50% faster in a dummy application!

In Rails 1.2, a lot of time is spent in the session store. Let’s see what happens if we specify “session: off” in both applications:

Rails 1.2.6: 189.51 requests/sec

Rails 2.0.2: 246.69 requests/sec

 

Rails 2.0 is still 30% faster!

Also, we can see that the Rails team has been working actively on increasing the performance of the application. They achieved an increase in performance from rails 1.0 to 2.0.

Check back for more Ruby on Rails in part V!

You can leave a trackback from your own site.
Sorry, comments are closed for this post.