7
Dec

Better Performance for Ruby on Rails


Everyone knows how good Ruby on Rails is from the point of view of developing, maintaining and deploying applications easily and quickly. But the one question that every one seems to be asking “Is Ruby on Rails scalable?”. This is mainly because, not many people have heard of Ruby before. This normally creates the FUD around the language and framework.

These are some tips that can help increase the performance of your application. With this you should be able to at least improve the performance for you application 25 fold.

mod_ruby

When you use ruby in cgi mode the interpreter is loaded every time a request is made. mod_ruby embeds the Ruby interpreter into the Apache web server, allowing Ruby CGI scripts to be executed natively. This is just like the mod_php apache module that everyone uses.

fcgi

FastCGI is a language independent, scalable, open extension to CGI that provides high performance without the limitations of server specific APIs. When fcgi is enabled the entire framework is cached. People have experienced over 10x performance increase by using fcgi alone. There is also a Apache module available for fcgi you can find it here.

Cache static pages

Ruby on Rails now allows you to cache methods. This is really good if your creating a website with static pages.

  caches_action :index, :node

This is a must if your application has static pages.

C binding for the database

This is a highly recommended. For the main reason that using the c bindings for the database is faster than using the native ruby based Active Records adapter. These bindings are not hard to install. If Ruby on Rails finds these bindings installed it will automatically use the c bindings instead of its native ruby based ones. I guess this speaks for itsself. This is where you can get the MySQL Binding and the PostgreSQL Binding.

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <apache>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options