Reputation: 377
The documentation for net/http/pprof explains how to create a 30-second CPU profiling session and analyze the outcome.
This allows me to initiate one or more HTTP requests and see the resulting CPU utilization of my web application.
I see a route for generating a heap profile, but since the profiling doesn't occur over something like a 30-second window, I'm unsure conceptually how this interacts with my web application.
How can I "coordinate" the heap profiler so that it corresponds with one or more HTTP requests?
Upvotes: 1
Views: 965
Reputation: 55962
I don't think you can scope the profiler exactly to a request, but a common methodology is to take multiple, intentionally timed, heap profiles. For example:
The powerful part of heap profiles is that pprof allows you to "diff" a profile by specifying 2 profiles! a base profile and a secondary profile to compare the base to!
Using this it becomes easy to see the difference in allocated objects or total bytes.
Upvotes: 3