Skip to content

Profile page using rack mini profiler

Dani Donisa edited this page Jan 11, 2024 · 5 revisions

If you need to profile component, we suggest to use https://github.com/MiniProfiler/rack-mini-profiler

To avoid to change the development permanently, you can do it on demand.

How to run it

Start your frontend container as:

docker compose run --rm --service-ports frontend bash -c "bundle exec rake ts:start && bash"

Edit your Gemfile and add the following lines:

 gem 'rack-mini-profiler'
 gem 'flamegraph'
 gem 'stackprof'
 gem 'memory_profiler'

Then run bundle install and start the server with rails s -b 0.0.0.0

Open your browser, navigate to the page that you want profile and voilà

Why we don't have it in the Gemfile disabled?

Because it's noted that it can behave bad with the cache leading to unexpected behavior, We prefer to keep it out for now.

To have it installed and disabled and being able to load it when necessary could be an option too.

It would be even possible to setup in Production:

https://github.com/MiniProfiler/rack-mini-profiler#access-control-in-non-development-environments

Some reference with screenshots: https://stackify.com/rack-mini-profiler-a-complete-guide-on-rails-performance/

Clone this wiki locally