Go for Infrastructure
Goroutine scheduling: failure analysis
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.
What you will be able to do
- Find a goroutine leak with a goroutine count and a debug=2 dump.
- Decide where a blocked send needs a select on a context or done channel.
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
- 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.
- GMP scheduler: operational verificationAdvanced · 5 min
Explain how GOMAXPROCS caps parallel Go code, how threads and processors relate to goroutines, and why too many threads stall under a CPU quota in a container.
- Channels: failure analysisAdvanced · 5 min
Explain how sends and receives block on channels, why a nil or unowned channel hangs, and how a select with a context case lets blocked goroutines exit.
- Select fairness: operational verificationAdvanced · 5 min
Explain how select chooses among ready channels by uniform pseudo-random selection, so source order gives no priority, and how a nested select can give one channel…
- Context cancellation: failure analysisAdvanced · 4 min
Explain how a Go context cancels work, why a deadline does not stop a goroutine on its own, and how to find the calls that ignore it.