When running in serverless mode, in particular with AWS Lambda, it has been noted that the Garbage Collector (GC) does not adequately keep up with freeing past execution allocations when handling high rates of requests. As a result, memory allocation grows with reuse of the same lambda container across invocations. This eventually leads to the the container being killed by the Lambda service.
GOMEMLIMIT can be set as an environment variable. Go will recognize the value as a 'soft' memory limit and start to more aggressively execute GC once reached.
When running in serverless mode, in particular with AWS Lambda, it has been noted that the Garbage Collector (GC) does not adequately keep up with freeing past execution allocations when handling high rates of requests. As a result, memory allocation grows with reuse of the same lambda container across invocations. This eventually leads to the the container being killed by the Lambda service.
GOMEMLIMIT can be set as an environment variable. Go will recognize the value as a 'soft' memory limit and start to more aggressively execute GC once reached.