a specific performance problem we had *What I learned about go from this experience Setting yourself up for success with pprof *Why you might want to profile your production services *How you should prepare to do it
about • https://mmcloughlin.com/posts/your-pprof-is-showing • Anything can register a route! Instead • Start with a clean mux and server mux !:= http.NewServeMux() srv !:= &http.Server{Addr: “8080”, Handler: mux} • Import net/http/pprof and expose what you need, or use middleware to do the lifting • eg. https://github.com/go-chi/chi/blob/master/middleware/profiler.go
and internal state • Increased surface area Instead • Restrict access to it • Put your pprof endpoints behind auth • Run on a non-public IP and port srv !:= &http.Server{Addr: “127.0.0.1:9090”, Handler: mux} • Respond to a signal $ kill -USR1 $PID
process • Negligible in my cases - what about yours? Instead • Look at the perf impact under controlled conditions • Gain confidence that you can use it when you need it
use them when you need to • You don’t want to read StackOverflow at 3am Instead • Regularly use your tools. It’s a dress rehearsal • Use your alerts and incident runbooks to tell you what to do • Do it the same way across all your systems