I am running a lambda function on AWS that takes a very long time to execute (big data).
It is exceeding the maximum 900 seconds (15 minutes) allowed in lambda, so the function is timing out.
Using context.getRemainingTimeInMillis(), I am thinking to trigger a new instance of the lambda just before getting the timeout. However, looks like there is no way to stop the execution of a lambda, once it is started, meaning that if I make any mistake, we could enter in a infinite loop and lambda would be running forever??
Anyway, to avoid this, I am thinking to set a environment variable called "stopExecution", which defaults to false, but in case for some reason I need to stop the execution, set it up to true.
Basically in my nodejs code I read the variable process.env.stopExecution. Now, my question is, the environment variables in a lambda, are dynamic? If I change the value during the execution, the lambda will read the new value and therefore stop? Or the environment variables are only read at the launch time of the function, and they keep the same value during the execution, so the only way to read the new value is to wait for them to stop and launch them again?
Also, if some faced the same issue as myself and wants to propose a better solution, feel free.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…