Golang & Concurrency (50 Qs)•Part 4: Production Compilation, Tooling & Senior Engineering (39 - 50)
How do you analyze CPU and Memory Profiles with `pprof`?
mid LevelgolangProduction Compilation
In Simple Words:
- Import
_ "net/http/pprof"in your microservice. - Capture a 30-second CPU profile:
go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30. - Inspect memory allocations:
go tool pprof -alloc_space http://localhost:6060/debug/pprof/heap. - Generate SVG Flame Graphs to pinpoint exact bottleneck functions.