10 ways and tools to measure performance of a rails application
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.
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.
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.
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.
It is a debugging toolbar for Rack applications implemented as middleware.
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