Goroutine Pool Patterns in Go: errgroup & Backpressure

Answer-first: Unbounded goroutines in production trigger OOM crashes and garbage collection spirals. Prevent failures by enforcing concurrency limits using errgroup.WithContext for group error handling, channel-based worker pools for continuous jobs, and buffered semaphores for rate-limiting, transforming variable runtime resource usage into predictable, fixed bounds. What You’ll Learn That AI Won’t Tell You Preventing goroutine leaks in high-concurrency worker pools using errgroup. Writing robust worker pools that propagate context cancellation to all active goroutines. Every Go engineer eventually writes the same mistake: a loop that launches goroutines unconditionally. In a demo with 10 items, this works beautifully. In production with 50,000 incoming webhook events, it spawns 50,000 goroutines simultaneously, exhausts memory, and triggers the OOM killer. Kubernetes restarts the pod. The on-call engineer gets paged at 3 AM. ...

June 1, 2026 · 14 min · Lê Tuấn Anh

Goroutine Leak Detection and Fix in Production Go Services

Answer-first: Goroutine leaks block indefinitely and hold GC roots, leading to slow, silent memory exhaustion and pod restarts. Pinpoint leaks by comparing pprof profile snapshots (specifically goroutineleak in Go 1.26), write deterministic tests with Go 1.24’s synctest, and set automated telemetry alerts on active goroutine counts. What You’ll Learn That AI Won’t Tell You Writing automated test cases that detect goroutine leaks before deploying. Analyzing production runtime stack traces to locate orphaned channels. A Kubernetes pod abruptly restarts with exit code 137. The memory metrics dashboard shows a slow, perfectly linear staircase pattern stretching over three days. There are no panic logs in stdout, no database errors, and no abnormal CPU spikes. Just a slow, silent OOM (Out Of Memory) death. ...

May 26, 2026 · 16 min · Lê Tuấn Anh