Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda: The function is idle

I am studying Lambdas of my project and I've seen that one of them is idle. In the top of dashboard page I see block with text:

The function __ is idle. To reactivate your function, choose Restore.

I slightly confused of it because this function is very similar to others which isn't marked as idle but as well haven't been launched for couple of months. Since I haven't find answers in AWS documentation i'd appreciate somebody to explain me what difference between functions in idle state and not, and how/why function becomes Idle?

like image 420
Yevhenii Avatar asked May 25 '20 15:05

Yevhenii


People also ask

Why does my Lambda function timeout?

There are three reasons why retry and timeout issues occur when invoking a Lambda function with an AWS SDK: A remote API is unreachable or takes too long to respond to an API call. The API call doesn't get a response within the socket timeout.

How do you keep a Lambda function running?

First, open up the AWS console (and yes, there is a way to do this via CLI) and go to CloudWatch. From there, go to Events and click Create rule . Set the event type to Schedule , and run this event every 1 minute. Then select the Lambda function you want to target from the Targets list and save.

How long does AWS Lambda keep your idle functions around before a cold start?

A cold start occurs when the container is shut down and then has to be restarted when the lambda function is invoked, typically this happens after ~5 mins of inactivity.


2 Answers

It is related to VPC, please check this doc.

If your functions aren't active for a long period of time, Lambda reclaims its network interfaces, and the functions become Idle. To reactivate an idle function, invoke it. This invocation fails, and the function enters a Pending state again until a network interface is available.

https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html

like image 91
Traycho Ivanov Avatar answered Oct 05 '22 11:10

Traycho Ivanov


Instead of a Cloudwatch event, I would suggest using Provisioned Concurrency to keep a lambda(s) warm.

https://aws.amazon.com/about-aws/whats-new/2019/12/aws-lambda-announces-provisioned-concurrency/

like image 42
kmontevecchi Avatar answered Oct 05 '22 12:10

kmontevecchi