
Rack-Mini-profiler – The Secret Weapon of Ruby and Rails Speed - aaronbrethorst
https://www.nateberkopec.com/2015/08/05/rack-mini-profiler-the-secret-weapon.html
======
sergiotapia
Another tool that helped us out tremendously was
[http://stackshare.io/skylight](http://stackshare.io/skylight).

It allowed us to quickly determine what pages were slowest and why, but also
what pages were being hit the most by users. Sorting by 'agony' means: "This
page is a combination of being hit the most, and the slowest. Take care of it
pronto."

Amazingly, we started knocking out 'agony' problem areas, and our site is
super quick now with minimal effort.

Here's an example of what their dashboard looks like:

[http://i.imgur.com/b4zhh6Q.png](http://i.imgur.com/b4zhh6Q.png)

~~~
bdcravens
I've tried out Skylight, but if you already have New Relic, didn't see
anything new.

~~~
sergiotapia
NewRelic's UX is ABYSMAL. It has not once given us useful insight into
anything.

------
sams99
Thanks heaps Nate for the writeup!

Some other resources on rack-mini-profiler are:

[https://samsaffron.com/archive/2013/03/19/flame-graphs-in-
ru...](https://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-
miniprofiler)

[https://samsaffron.com/archive/2012/07/12/miniprofiler-
ruby-...](https://samsaffron.com/archive/2012/07/12/miniprofiler-ruby-edition)

Some history:
[https://samsaffron.com/archive/2011/06/09/+Profiling+your+we...](https://samsaffron.com/archive/2011/06/09/+Profiling+your+website+like+a+true+Ninja)

My talk, measuring Ruby [https://www.youtube.com/watch?v=LWyEWUD-
ztQ](https://www.youtube.com/watch?v=LWyEWUD-ztQ)

And Off the Rails
[https://www.youtube.com/watch?v=aP5NNkzb4og](https://www.youtube.com/watch?v=aP5NNkzb4og)

------
yoran
The development mode of New Relic
([https://docs.newrelic.com/docs/agents/ruby-
agent/developer-m...](https://docs.newrelic.com/docs/agents/ruby-
agent/developer-mode/developer-mode)) is another good tool to find out about
response times of your controller actions and the number of SQL queries. I'm
pretty sure you can use it even if you're not on a paying plan for New Relic.
We switched to this after we weren't been able to get rack-mini-profiler to
work in a Rails app for a single-page app as the Rails app only returns JSON
and doesn't render templates.

------
matthuggins
> If you're forcing SSL in production, you're going to want to turn that off
> for now.

Great article, but there's no further mention about SSL. Specifically, why
should I turn it off in the first place for this gem, and when/how can I turn
it back on? Is there some special step(s) needed to do so, and what are they?

~~~
btucker
It's because the article takes you through running your app in production
environment locally on your machine. To do that with ssl you'd need to get
that setup locally as well, so I think the author just wanted to avoid dealing
with that.

~~~
nateberkopec
Correct - that's exactly what I meant. Don't turn your SSL off on your
production _server_ just to run this gem - that'd be silly!

------
spo81rty
I've never used it but there is also something called Rails Panel someone
might find useful:
[https://github.com/dejan/rails_panel](https://github.com/dejan/rails_panel)

------
hiphopyo
Hasn't Peek ([https://github.com/peek/peek](https://github.com/peek/peek))
sorta replaced Rack-Mini-Profiler?

~~~
ebola1717
What's better about Peek?

------
orf
> To see a full list of rack-mini-profiler's features and info on how to
> trigger them, add ?pp=help to the end of any URL

Wait... in production? Anyone can do this?

~~~
matthuggins
My guess is that this blurb is relevant:

> rack-mini-profiler runs in the development environment by default in Rails
> apps. We're going to enable it in production, and hide it behind a URL
> parameter. You can also do things like make it visible only to admin users,
> etc.

------
spo81rty
Are there tools like this for other languages? For asp.net there is Glimpse
and the Mini profiler. What about Java, php, node, python?

~~~
mediumdeviation
For PHP there is PHP Debug Bar -
[http://phpdebugbar.com/](http://phpdebugbar.com/), although if you're using a
framework you'd want to find the fork with the bindings. I'm using the one for
Laravel and it's pretty good [https://github.com/barryvdh/laravel-
debugbar](https://github.com/barryvdh/laravel-debugbar)

~~~
troels
There's also xdebug, which can give a lot of detailed information. And then
there's New Relic for PHP.

------
rubiquity
Good post but please, please, please don't enable this in productiont. What an
extremely wonderful way to DDoS any Rails app (as if it weren't easy enough
already). If you need production like characteristics for accuracy of
profiling then set up another environment that is production-like (Rails
settings, replicated database, infrastructure etc.) and run it there.

~~~
nateberkopec
You can put `rack-mini-profiler` behind authentication. It is not enabled by
default in production. I believe I mentioned this in the article, if not, it's
in the README.

~~~
rubiquity
I would try and word it more carefully. The phrase "in production" has serious
meaning. I think that's what startled myself (and it seems like some others,
too).

~~~
madebysquares
Although your take away may have been that everyone should enable it in
production. I think every developer should use common sense and practical
knowledge when implementing a feature in their application. If you want to use
it you should know that having this available for all users is not a great
idea, and use it accordingly.

~~~
rubiquity
You would be surprised by the lack of common sense in the software community.
Maybe even more so in Ruby/Rails. As an example, there are a lot of people
running WEBrick in production.

------
programminggeek
The secret to rails speed is not using rails at all.

~~~
gregmolnar
Yeah, better to use assembly and spend a week to implement trivial features :)

