jeremydaly / lambda-warmer

A module to optimize AWS Lambda function cold starts
MIT License
525 stars 55 forks source link

Lambda timeout for concurrency bigger than 1 #55

Closed anebz closed 1 year ago

anebz commented 1 year ago

Whenever I activate concurrency greater than 1, my Lambda times out.

My Lambda code looks like this:

exports.handler = async function (event, context) {
    if (await warmer(event, { correlationId: context.awsRequestId, delay: 50 })) {
        return {
            "statusCode": 200,
            "body": JSON.stringify({
                status: 200,
                title: "Warmed"
            })
        };
    }
    else {
        // do other stuff
    }
}

I have a Rule with a rate of 5mins, targeting my Lambda with the constant input:

{
  "warmer": true,
  "concurrency": 5
}

and the Lambda times out. if I change the concurrency to 1, it runs normally.

I've granted Lambda the right to invoke itself.

I'm using NodeJS V16, and these versions:

anebz commented 1 year ago

Problem solved, it had nothing to do with this plugin at all 😅 the Lambda was inside a VPC and it wasn't invoking itself because I was missing the interface endpoint for the VPC. I added that and now it works.