How long before idle Lambda function transitions to Inactive state?

384 views Asked by At

Following this AWS blog, I can see that

A function transitions to the Inactive state when it has been idle long enough for the Lambda service to reclaim the external resources that were configured for it.

So what is long enough? I have Lambda functions deployed in a VPC that may be idle for weeks or months, and I'd like to avoid the Lambda.ResourceNotReadyException and subsequent 502 status codes my client receives because the function is Inactive and a new network interface needs to be configured.

I just need the Lambdas to remain in Active state; don't need warm starts so not wanting to pay for Lambda's Provisioned Concurrency. I'm thinking to just trigger each Lambda in the VPC with a CloudWatch Event on some regular interval. I assume I could trigger once per day but really curious if I can find a more optimal solution here.

1

There are 1 answers

0
Ermiya Eskandary On BEST ANSWER

long enough is ~14 days.

I've gone through every mention of inactive & idle in the AWS Lambda docs.

The blog post you have linked mentions 'long enough':

A function transitions to the Inactive state when it has been idle long enough for the Lambda service to reclaim the external resources that were configured for it.

The Lambda function states section of the docs also mentions 'long enough':

Inactive – A function becomes inactive when it has been idle long enough for Lambda to reclaim the external resources that were configured for it.

The Private Networking section of the docs mentions 'consecutive weeks':

If a Lambda function remains idle for consecutive weeks, Lambda reclaims the unused Hyperplane ENIs and sets the function state to idle.

However, the Lambda SnapStart and function states section of the docs is as closest as we get to a real answer: '14 days'.

Inactive – The function version hasn't been invoked for 14 days. When the function version becomes Inactive, Lambda deletes the snapshot.

My own testing also validates it to be approximately ~14 days.


I've submitted feedback to the AWS Lambda team to update the documentation to be more clear, or provide reasoning as to the lack of clarity on duration. It's unfortunate that it's not consistent.

I'll update my answer if/when I hear back.