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. This PR sets the GOMEMLIMIT environment variable (both in AWS and GCP) at a default value of 90% max allocated memory. GOMEMLIMIT is a soft memory limit that Go will recognize 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. This PR sets the GOMEMLIMIT environment variable (both in AWS and GCP) at a default value of 90% max allocated memory. GOMEMLIMIT is a soft memory limit that Go will recognize and start to more aggressively execute GC once reached.
Resolves silverton-io/buz/issues/591