idea is from this article How We Saved 70K Cores Across 30 Mission-Critical Services (Large-Scale, Semi-Automated Go GC Tuning @Uber)
just call NewTuner when initializing app :
func initProcess() {
var (
inCgroup = true
percent = 70
)
go NewTuner(inCgroup, percent)
}
Go 1.19 adds a soft memory limit which changes its pacer algorithm and scvg behavior, we'll see what go team will provide in the new version. Maybe this lib can be deprecated in Go 1.19.
official guide for gogc and memory limit params: