Mistake: assuming concurrent garbage collection eliminates application pauses. Go’s collector still performs stop-the-world phases that suspend application code while runtime work uses the available CPU time. section 12.9.1
Go’s concurrent mark-and-sweep collector limits, rather than removes, these pauses. Each GC performs two stop-the-world periods before resuming application execution alongside a concurrent phase. section 12.9.1
Diagnose and reduce stop-the-world impact according to the workload:
- For sudden heap growth, consider increasing GOGC to reduce GC frequency, but validate under production load because larger heaps take longer to clean. section 12.9.2
- For an extreme, known allocation peak, preallocate a large global buffer so the heap reaches the next GC threshold less frequently. section 12.9.2
- Use GC tracing during investigation with GODEBUG=gctrace=1 go test -bench=. -v. section 12.9.1
A sudden connection spike
If nearly one million users connect within an hour, rapid heap growth can trigger frequent GC cycles and significant stop-the-world periods, increasing average latency. Increasing GOGC may reduce the pressure; if the spike occurs within seconds, a planned 1 GB allocation can defer collection by raising the heap threshold. section 12.9.2
Use the GC-frequency figure to relate a one-hour user surge to the concentration of collection cycles that produces pause impact. section 12.9.2

