For a more fair comparison, you should set the GOGC environment variable to off to disable Go's garbage collector. Stress tests and benchmarks will trigger a lot of collections that will occur very differently (when the server is idle on the happy path) when handling real-life traffic, which tends to distort comparisons (it's also possible to change the ratio instead).
If you're using containers with a small amount of available memory, you should also GOMEMLIMIT, this can dramatically improve performance.
For a more fair comparison, you should set the
GOGC
environment variable tooff
to disable Go's garbage collector. Stress tests and benchmarks will trigger a lot of collections that will occur very differently (when the server is idle on the happy path) when handling real-life traffic, which tends to distort comparisons (it's also possible to change the ratio instead).If you're using containers with a small amount of available memory, you should also
GOMEMLIMIT
, this can dramatically improve performance.More info: