Home > Net >  Why is AWS Lambda resetting every ~2hrs even with regular ping from EventBridge?
Why is AWS Lambda resetting every ~2hrs even with regular ping from EventBridge?

Time:09-27

I have a Lambda function that has an unacceptably long start-up time due to large files being transferred on initialisation. Once this is done, the actual data processing is very quick

I've set up a rule with EventBridge that keeps the function warm by sending a dummy request every 4 minutes. I've set these dummy requests up such that they only take a few ms after the initial request.

For this most part this seems to be working well - on the logs I see one long request and then all of the ones afterwards are quick.

However, I notice that every 128 minutes I get another long request, as if the Lambda function is 'resetting', despite the warming rule.

Does anyone know why this is happening? I don't understand why I'm getting these intermittent long requests if the function is being kept warm..

CodePudding user response:

A lambda function instance has a maximum lifetime of about 2 hours even if it's in use. If you want to keep an instance alive then you should use provisioned concurrency.

CodePudding user response:

What Matt said above is true, you should use provisioned concurrency. But you can also speed up the cold start by using lambda layers to include files there, instead of downloading on initialization (if the files you need to download don't change frequently).

  • Related