How to increase dgraph lambda max memory limit?

I’m fetching some information and I want to insert them into the database using a Lambda Server(using docker localy).
The problem is that it uses 70MB of memory and Dgraph Lambda PM2 restarts the process each time I call this service:

2021-12-25T08:41:17: PM2 log: pid=52 msg=process killed
2021-12-25T13:47:39: PM2 log: [PM2][WORKER] Process 1 restarted because it exceeds --max-memory-restart value (current_memory=72474624 max_memory_limit=67108864 [octets])
2021-12-25T13:47:39: PM2 log: App [dgraph-lambda:1] starting in -cluster mode-
2021-12-25T13:47:39: PM2 log: App [dgraph-lambda:1] online
Server Listening on port 8686!

I took a look at the source and apparently this limit is hard coded here:

Also found another pull request that was because of a similar issue:

Shouldn’t max_memory_limit be an environment variable that people can set their desired memory limit?

1 Like

I created this PR. I think it will solve the issue both for max memory limit and the number of PM2 instances. Also checked it by building the docker image locally.

Can anyone review this?

1 Like

The PR looks good. Thanks, @pshaddel!