Go goroutine leak cpu
Go goroutine leak cpu is typically caused by a compute-bound bottleneck where one or more processes are saturating CPU cores. Here is what to look for and what to do about it.
Common symptoms
- Go process CPU climbs over time
- memory usage grows alongside CPU
- goroutine count increases without bound
Likely causes
- Evidence suggests: pprof shows growing goroutine count
- Evidence suggests: blocked goroutines accumulating on channel ops
Evidence to look for
pprof shows growing goroutine count
blocked goroutines accumulating on channel ops
GC pressure increasing with goroutine count
What it usually means
When CPU is the true bottleneck, the fix is usually profiling the hot path and reducing compute work. Scaling horizontally or vertically without profiling first is wasteful.
What to do next
- 1use runtime/pprof to dump goroutine stacks
- 2check for goroutines blocked on unbuffered channels
- 3add context cancellation to long-running goroutines
See what's causing your CPU
cpum.ai turns CPU, process, disk, and memory signals into plain-English explanations with evidence.
Open cpum.ai