Five tools for profiling Rails apps

BY Doug Breaker

March 01, 2017

Starting with Fiveruns TuneUp in 2008, a number of in-browser Rails profilers have come, gone, or continue to exist but in a zombie-like half-alive state. Finding profilers that reliably work in 2017 with little effort was a bigger challenge than I thought. Here's a 2017 summary of the Rails profiler ecosystem: what works, what doesn't, and each profiler's niche.

rack-mini-profiler

miniprofiler

While its name might include "mini", rack-mini-profiler is actually the feature-packed beast of Rails profiling options. rack-mini-profiler instruments database calls, profiles the callstack with flamegraphs, and provides a number of memory-related metrics.

rack-mini-profiler "just works" against the Rails 4 and Rails 5 apps I tested.

rack-mini-profiler pros

rack-mini-profiler cons

DevTrace

devtrace

DevTrace is Scout's free Rails profiler and is included with the scout_apm gem. DevTrace provides the same level of traces Scout provides for app monitoring - instrumenting view rendering, database calls, and memory allocations.

When run with ScoutProf, Scout's stack profiler, it also profiles your custom code.

DevTrace "just works" for Rails apps.

DevTrace pros

DevTrace cons

Scout Rails app monitoring with built-in intelligence: Scout identifies N+1 queries, memory bloat, slow Ruby code, and more. Try Scout today.

Rails Panel

rails panel

One part Ruby gem and one part Chrome extension, Rails Panel exposes details on your app's requests in the Chrome Developer Panel. Rails Panel instruments ActiveRecord and rendering calls.

Rails Panel Pros

Rails Panel Cons

Profilers I struggled with

Which profiler should I use?

While rack-mini-profiler, DevTrace, and Rails Panel can run simultaneously without error, that's likely information overload. These are the sweet spots for each of the above profilers:

rack-mini-profiler

Not intimidated by lots of instrumentation data? rack-mini-profiler is a great fit for developers that enjoy detailed statistics on performance. This is a tool that's not afraid of dumping a significant amount of data into a developer's lap.

rack-mind-profiler is also the only option for two areas:

  1. Non-Rails apps (ex: Sinatra)
  2. Running in production

DevTrace

Do you value polish and filtering on performance metrics over a raw dump of data? DevTrace works to distill information: it provides timing, memory, and sampling data like rack-mini-profiler but in a more compressed presentation.

Rails Panel

Are you after a cleaner way to view your development log file and not deep transaction traces? Rails Panel fits the bill.

Also See

Subscribe for more

Want more Ruby insights like this delivered monthly to your inbox? Just put your email into the sidebar form.

Scout Rails app monitoring with built-in intelligence: Scout identifies N+1 queries, memory bloat, slow Ruby code, and more. Try Scout today.