You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/debug_python_with_pyroscope.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -23,10 +23,11 @@ During the period of 100% CPU utilization, you can assume:
23
23
24
24
The question is: **which part of the code is responsible for the increase in CPU utilization?** That's where flame graphs come in!
25
25
26
-
## How to use flame graphs to debug performance issues and save money
26
+
## How to use flame graphs to debug performance issues (and save $66,000 on servers)
27
27
Let's say the flame graph below represents the timespan that corresponds with the "incident" in the picture above where CPU usage spiked. During this spike, the server's CPUs were spending:
@@ -41,7 +42,7 @@ In this case, `foo()` is taking up 75% of the total time range, so we can improv
41
42
## Creating a flame graph and Table with Pyroscope
42
43
To recreate this example with actual code, we'll use Pyroscope - an open-source continuous profiler that was built specifically for debugging performance issues. To simulate the server doing work, I've created a `work(duration)` function that simulates doing work for the duration passed in. This way, we can replicate `foo()` taking 75% of time and `bar()` taking 25% of the time by producing this flame graph from the code below:
Then, let's say you optimize your code to decrease `foo()` time from 75000 to 8000, but left all other portions of the code the same. The new code and flame graph would look like:
# This would simulate a CPU running for 0.8 seconds
74
-
defa():
69
+
deffoo():
75
70
# work(75000)
76
71
work(8000)
77
72
78
73
# This would simulate a CPU running for 2.5 seconds
79
-
defb():
74
+
defbar():
80
75
work(25000)
81
76
```
77
+
## Improving `foo()` saved us $66,000
78
+
Thanks to the flame graphs, we we're able to identify immediately that `foo()` was the bottleneck in our code. After optimizing it, we were able to significantly decrease our cpu utilization.
This means your total CPU utilization decreased 66%. If you were paying $100,000 dollars for your servers, you could now manage the same load for just $34,000.
82
84
83
-
This means your total CPU utilization decreased 66%. If you were paying $100,000 dollars for your servers, you could now manage the same load for just $66,000.
0 commit comments