marcel-dempers / cpu-performance-analysis

CPU performance analysis demo for docker containers using FlameGraphs
33 stars 26 forks source link

Quickstart example guide to cpu performance analysis for Golang and .NET Core

CPU performance analysis demo for docker containers using FlameGraphs

VIDEO: YouTube sample

Get all the tools

1) Download my perf containers (My desktop repo). You will need the dockerfile and the docker-compose file here

Note: You need the dotnet core version of the application you are profiling. Check and adjust the dockerfile accordingly Change directory to where you downloaded those files and run docker-compose build to compile perf tools with dotnetcore SDK

2) Download the flamegraph container

docker pull aimvector/flamegraph

Start the sample stack

In this directory of this repo, run

docker-compose build
docker-compose up

While the stack is running you can profile it with the perf container

Option 1: Perf

Checkout the perf example here

Option 2: eBPF

Checkout the ebpf example here

KUBERNETES

The same process above works for Kubernetes containers as well. Instead of docker-compose, you will have to use the ./k8s.yaml file in this repo that runs the perf container in a pod in your cluster. Be warned! It's armed with priviledges so use with caution and delete it when done :)

Instead of docker cp, you can use kubectl cp to copy out.perf to your machine where you can run the above flamegraph container. So therefore the same concept applies in Kubernetes.

You can get the Linux kernel version of your node by running:

kubectl run alpine --image alpine -- /bin/sh -c "uname -r"