http server的pprof

Briefly describe how to use pprof to monitor the performance of http server.

Answer

  1. Add `import _ "net/http/pprof"` in the main.go
  2. Run the following commands to get info correspondingly:
  3. CPU profile:
  4. go tool pprof http://localhost:6060/debug/pprof/profile --second N
  5. heap profile:
  6. go tool pprof http://localhost:6060/debug/pprof/heap
  7. goroutine blocking profile:
  8. go tool pprof http://localhost:6060/debug/pprof/block