- rack-mini-profiler: Swiss-army knife profiler for rails apps
- flamegraph: Nice and useful timeline visualizer for debugging long methods.
- memory_profiler: Easy to use memory profiler for memory consuming methods.
- heapy: Memory dump analyzer for advanced memory analysis.
- foreman-tracer: great tool for unintrusive tracing by lzap.
Last active
December 3, 2018 14:41
-
-
Save ShimShtein/7761d9f2f2b1d38f76ca40e61f7197f6 to your computer and use it in GitHub Desktop.
Foreman performance analysis deep dive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SQL Logger: | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
# REST Logger: | |
require 'rest_client' | |
RestClient.log = | |
Object.new.tap do |proxy| | |
def proxy.<<(message) | |
Rails.logger.info message | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'rack-mini-profiler' | |
# # For memory profiling (requires Ruby MRI 2.1+) | |
gem 'memory_profiler' | |
# | |
# For call-stack profiling flamegraphs (requires Ruby MRI 2.0.0+) | |
gem 'flamegraph' | |
gem 'stackprof' # For Ruby MRI 2.1+ | |
gem 'fast_stack' # For Ruby MRI 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum install gcc | |
yum install rh-ruby22-ruby-devel | |
scl enable tfm "gem install stackprof flamegraph memory_profiler rack-mini-profiler" | |
# It's ugly, but it works: | |
cat <<EOF > /usr/share/foreman/config.ru | |
# This file is used by Rack-based servers to start the application. | |
require ::File.expand_path('../config/environment', __FILE__) | |
# add requires for rack-mini-profiler and enable it: | |
require 'memory_profiler' | |
require 'stackprof' | |
require 'flamegraph' | |
require 'rack-mini-profiler' | |
use Rack::MiniProfiler | |
# /add | |
# apply a prefix to the application, if one is defined | |
# e.g. http://some.server.com/prefix where '/prefix' is defined by env variable | |
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do | |
run Foreman::Application | |
end | |
EOF | |
systemctl restart httpd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment