Go for Infrastructure
Profiling with pprof
Explain what CPU, heap and goroutine profiles show, how to capture them during a problem, and how to read a top list and source lines with go tool pprof.
What you will be able to do
- Capture a CPU profile during a slow period and read its top functions.
- Choose the heap or goroutine profile that matches the symptom.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Go for Infrastructure
- Prometheus instrumentationIntermediate · 4 min
Explain why each unique label combination adds a Prometheus time series, and choose metric types, names and labels that stay bounded as the system grows.
- OpenTelemetry tracingIntermediate · 5 min
Explain spans, trace context propagation and sampling in OpenTelemetry, so the time one request spends can be followed across services, queues and background jobs, with…
- Memory escapesIntermediate · 4 min
Explain how escape analysis decides whether a value lives on the stack or the heap, and how to read compiler output and benchmark allocations before changing code.
- Garbage collection tuningIntermediate · 5 min
Explain how GOGC and GOMEMLIMIT set the trade-off between heap memory and garbage collection CPU, and how to leave headroom under a container memory limit.
- Graceful shutdownAdvanced · 5 min
Explain how a Go server drains on SIGTERM, so in-flight requests finish and the shutdown deadline fits inside the platform's grace period before SIGKILL arrives.
- Goroutine scheduling: failure analysisAdvanced · 4 min
Explain how parked goroutines keep their memory after they stop running, how to count and group them, and how to find the wait point that never returns.