-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
Thank you for putting together the diagnostics document, it is very useful for us people who's starting working with Go.
I'm creating this issue as I've additional doubts and @rakyll pointed me to here to ask for clarifications.
In the profiling section you have answered if it's possible to profile production services: I'm going to copy the answer here and add bold to the additional doubts that I have about it:
Yes. It is safe to profile programs in production, but enabling some profiles (e.g. the CPU profile) adds cost. You should expect to see performance downgrade. The performance penalty can be estimated by measuring the overhead of the profiler before turning it on in production.
You may want to periodically profile your production services. Especially in a system with many replicas of a single process, selecting a random replica periodically is a safe option. Select a production process, profile it for X seconds for every Y seconds and save the results for visualization and analysis; then repeat periodically. Results may be manually and/or automatically reviewed to find problems. Collection of profiles can interfere with each other, so it is recommended to collect only a single profile at a time.
This answer is very clear and concise, yet I've found myself trying to answer an additional question: how do one measure the overhead of the profiler? What do you mean by replicas, multiple copies of the same process running in the same machine?
I am guessing the answer might be obvious and it's escaping me due to my lack of enough experience, but I think that additional details like these could really improve the document.
Another question that I have was when reading about serving the profiler handlers in different path and port. The example used is:
mux := http.NewServeMux()
mux.HandleFunc("/custom_debug_path/profile", pprof.Profile)
http.ListenAndServe(":7777", mux)
However when I went to the net/http/pprof
documentation I couldn't find a reference to pprof.Profile
but rather I had to go to read the init
function of that package to find how to do it. Am I missing something or is it just a bug in the document?
I've also found some package mentions like context.Context
and httptrace.ClientTrace
that don't provide a link to the documentation, which I think could be more than useful.
Sorry for the length of this issue, and if the answers are simple yet eluding me. Thank you for taking the time to read it! I would like to become a Go contributor someday so I'm more than willing to make changes to this document, provided I find out how to answer these questions 😺