Skip to content

Instantly share code, notes, and snippets.

@ChrisCinelli
Last active November 9, 2021 05:56
Show Gist options
  • Save ChrisCinelli/f5c659d5a877beb5723eea5e81d1534b to your computer and use it in GitHub Desktop.
Save ChrisCinelli/f5c659d5a877beb5723eea5e81d1534b to your computer and use it in GitHub Desktop.
Flame graphs on AWS on a ELB
# Flame graph on EB AWS machines:
# Check http://www.brendangregg.com/blog/2014-09-17/node-flame-graphs-on-linux.html
# Change the run command to run the node process with:
# $ node --perf_basic_prof_only_functions index.js
ssh your.machine.net
sudo yum install perf
sudo sysctl kernel.kptr_restrict=0
sudo sysctl kernel.perf_event_paranoid=0
git clone https://github.com/brendangregg/FlameGraph
cd FlameGraph
sudo perf record -F 99 -a -g -- sleep 60
sudo chmod 777 /tmp/*.map
sudo chown root /tmp/*.map
sudo perf script | ./stackcollapse-perf.pl > out.perf-folded
# This will remove some noise...
perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ./stackcollapse-perf.pl > out.perf-folded
./flamegraph.pl out.perf-folded > node-flame.svg
# You can move the file with `scp` or if you want
# You can now download your svg on from the server putting the file in the public folder.
# Remember to removed it once you have transfered it.
sudo cp *.svg /var/app/current/dist/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment