10 ways and tools to measure performance of a rails application

July 9, 2011
Fuad

You had some unique business idea. You jot those down, thought about days after days, nights after nights! Then, you hired a talented bunch of developers, web designers, UX specialist. They built it using a great framework, say, Ruby on Rails, and you could see it in action that you were dreaming for months.

Your site is live now! Unfortunately, you do not have millions of dollars to spend on server (like Google or Facebook). You deployed it on a Linux box with limited memory. After a months of excitement, you realized that, users are encouraging enough in-terms of visit, but not enough to earn revenue. To make it worse, you found that, bounce rate is higher than anticipated. You ran some survey to find that users had some specific sets of expectations about responsiveness of the application, that your site couldn’t just meet. They wanted it to be quick, reliable, responsive — all your site isn’t.

Well, you didn’t consider this aspect when you assigned the project to the development team. What to do now?

This is where performance enhancement comes into place. To dig further, you need to start gathering data about performance of your system because people are quite bad at predicting which part of a computer program has the biggest performance problems. Once you find bottlenecks, you can solve your problem easily.

Here are some tips for you to measure and monitor performance in a Ruby on Rails application. Some tools and tips are equally applicable for other web applications.

1. Rails Performance Test – Benchmarking

Through Rails performance test, source of application’s memory or speed bottleneck and can be found. Benchmarking helps find out how fast each performance test runs. Each test case is run 4 times in benchmarking mode.

2. Rails Performance Test – Profiling

Profiling helps you to see the details of a performance test and provide an in-depth picture of the slow and memory hungry parts. Each test case is run 1 time in profiling mode.

3. Rails logger

The simplest way to get information about performance is to analyze rails log. It will provide you information of the time spent processing each request, broken down into rendering and SQL time. You can also find whether a particular part are cached or the occurrence of cache expiry.

4. Rails analyzer

The Rails Analyzer project contains a collection of tools (The Production Log Analyzer, The Action Profiler, Rails Analyzer Tools, The SQL Dependency Grapher) for Rails that let you discover biggest slow spots in your applications allowing you to best focus optimization efforts.

5. Rails footnote

It is a rails plugin which displays footnotes in your application for easy debugging, such as sessions, request parameters, cookies, filter chain, routes, queries, etc. Even more, it contains links to open files directly in your editor including your backtrace lines.

6. Query Reviewer

Query Reviewer is an advanced SQL query analyzer. It generates a page with explanation output of all SELECT queries, rate a page’s SQL usage, display interactive summary on page.

7. Slim Scrooge

SlimScrooge is an optimization layer to ensure your application only fetches the database content needed to minimize wire traffic, excessive SQL queries and reduce conversion overheads to native Ruby types.

SlimScrooge implements inline query optimization, automatically restricting the columns fetched based on what was used during previous passes through the same part of your code.

8. New Relic

New Relic is the all-in-one web application performance tool that lets you see performance from the end user experience down to the line of application code. It will also list the errors if such occurrence occur.

9. Rack-bug

It is a debugging toolbar for Rack applications implemented as middleware.

10. Firebug

Firebug is a firefox plugin and a very powerful tool. Thanks to Joe Hewitt for this life saver. Apart from many outstanding features, it helps to monitor network performance. You can see the load time of each files (when they started to load and when they are completed), filter it by type (e.g. javascript or CSS) and examining http headers.

That’s it! You can suggest more. These are a mere introduction. You can try those out and examine the health of your application. I have a plan to write another one with tips regarding enhancing performance based on the generated health report of a web application. Stay tuned for that!

Contributor: Fuad Bin Omar, COO, Nascenia

4 Comments. Leave new

Nice writeup. Have you considered using YSlow? I know Yahoo out a guideline, not specific to rails, but is considered a great help for most web apps. http://developer.yahoo.com/performance/rules.html

Reply

Sohan, you are spot on! Yeah, YSlow is a good tool that I missed 🙂 , thanks a lot.

Reply
nhm tanveer hossain khan
November 3, 2011 10:18 pm

Old fella! “openload” i’m still using it for stress testing while turned on mysql slow query 🙂 + query reviewer + exception notifier

Reply

[…] my previous article, I wrote about “10 ways and tools to measure performance of a rails application” . In this article I will give you 10 tips to boost up performance of you ruby on rails […]

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.